void loop()

The void loop() is the loop that runs contiously. I also want to keep this section of the code clean and simple. To do that I am just going to see if there is any data on the serial port to be read. If so then I am going to clear out the cmd string, delay for 5ms just to ensure all the data is across, and then run a custom function called serial_input() to proccess the data.

void loop() {
  if(Serial1.available()){ // is there any bytes on the serial 1 port buffer
    cmd = "";
    delay(5);
    serial_input(); // custom function to handle the messages over serial 
  }
}

Last updated