void setup()

This section of the code is executed once at startup. This is were you can initialize code or just run a task once when the device first powers on.

For this application I need to open the serial port that the Nextion will use to send messages to the Arduino Nano Every. I also need to define the relay pins as outputs.

void setup() {
  // open serial port with computer; use for debugging  
  //Serial.begin(9600); 
  
  // open serial port between HMI and Arduino Nano Every; recieve and send messages
  Serial1.begin(9600); 

  pinMode(relay1, OUTPUT); // configure relay 1 pin as an output
  pinMode(relay2, OUTPUT); // configure relay 2 pin as an output
}

Last updated