Hi!
Felt like an expert for a short while when creating a counter that is increasing to alter between messages on a display.
But now I am back to the newbie / rookie feeling again. ![]()
I run this code once every second to update the display, mostly because the clock should be ticking.
But when an alarm is triggered I want to show a message for a few seconds.
I have also more messaged to alter between (depending on if the bool = true).
But I do not manage to get it working.
The "else"-statement is always true and my counter directly jumps to 16 after showing Message 1, and then to 21 to then be reset to 0.
I marked the problem area with "NOT A GOOD IDEA...."
I'm so stuck.. Maybe the whole approach is wrong?
void updateLCDloop() {
 // localInternetErrorCount
 if (localInternetErrorCount > 1) {
  lcd.setCursor(0, 0); lcd.print(" No Internet...");
  updateLCD_1s_Flag = false;
 }
 else {
  // Message 1
  if ((msgCount >= 0) && (msgCount < 10)) {               // Updates the time on display.
   updateCurrentTime(lcd);
   ++msgCount;
   lcd.setCursor(2, 1);  lcd.print(msgCount);
  }
  // Message 2
  if ((alarmStatus == true) && (msgCount >= 10) && (msgCount <= 15)) {  // If alarm is active, do this.
   ++msgCount;
  } else {
   msgCount = 16;                         //  < === NOT A GOOD IDEA.....
   Serial.println(msgCount);
  }
  // Message 3
  if ((someOtherShit == true) && (msgCount >= 16) && (msgCount <= 20)) {
   ++msgCount;
  } else {
   msgCount = 21;                          //  < === NOT A GOOD IDEA.....
   Serial.println(msgCount);
  }
  // More messages to be added..
  //
  if (msgCount == 21) {
   msgCount = 0;
  }
 }
 updateLCD_1s_Flag = false;
}