> For the complete documentation index, see [llms.txt](https://brlabelectronics.gitbook.io/tutorials-1/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://brlabelectronics.gitbook.io/tutorials-1/control-relays-with-the-nextion-hmi-and-arduino/nano-every-code/writing-the-code/define-global-variables.md).

# Define Global Variables

Now we need to define some global variables that the code will use to define things such as digital outputs and string variables to store messages in.

```arduino
const int relay1 = 7; // relay 1 is on digital pin 7
const int relay2 = 8; // relay 2 is on digital pin 8

String cmd =""; // string variable to store messages in
```

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. In this case I am going to use D7 for relay 1 and D8 for relay 2.

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

We also need a string variable to store the serial data in so that they can be proccessed.&#x20;
