Define Global Variables

Now we need to define some global variables that the application will use to define things such as, digital outputs, relay states, relay pin array, and a character array that will hold the authentication token to connect to the Blynk cloud.

// Global Variables
char auth[] = BLYNK_AUTH_TOKEN; // defines the character array auth
const int relayPins[] = {5, 6, 7, 8}; //defines the relay pins in an array as constant intgers
const int relay1 = 5; // variable for controlling digital I/O pin 5 on the Argon
const int relay2 = 6; // variable for controlling digital I/O pin 6 on the Argon
const int relay3 = 7; // variable for controlling digital I/O pin 7 on the Argon
const int relay4 = 8; // variable for controlling digital I/O pin 8 on the Argon
volatile int relayState1 = LOW; // volatile variable for reading the current state of the relay, also setting it to LOW 
volatile int relayState2 = LOW;
volatile int relayState3 = LOW;
volatile int relayState4 = LOW;

We need to be able to control each relay with a digital I/O pin from the device thus we define a variable that is of the constant integer type and set it equal to the I/O pin that is going to be used to send the signal to the circuit that will energize the relay coil.

A constant integer means that the variable can not be redefined later in the code.

Last updated