Trying to Use Millis to Display Text on LCD

I'm trying to display two different lines of text in this function on the second line of an 16x2 LCD with 3 second intervals. The first line of "Clear the track" should display for 3 seconds then the second line of "and press button" for another three seconds. It should then go back to "Clear the track" and start over. My sketch compiles and uploads fine, but I only ever see the "and press button" on the second line. I never see "Clear the track". Where did I go wrong with my logic?

void callibrate_scale() {
    lcd.clear();
    secondLine = false;
    Serial.println("Callibrating... Clear the track and press button.");
    startTime = millis();
    while (digitalRead(TareCalButton) == HIGH) {
      lcd.setCursor(0,0);
      lcd.print("Callibrating... ");
      if ((millis() <= startTime + 3000) && (secondLine = false)) {
        lcd.setCursor(0,1);
        lcd.print("Clear the track ");
      }
      else if ((millis() > startTime + 3000) && (secondLine = false)) {
        secondLine = true;
        startTime = millis();
      }
      if ((millis() <= startTime + 3000) && (secondLine = true)) {
        lcd.setCursor(0,1);
        lcd.print("and press button");
      }
      else if ((millis() > startTime + 3000) && (secondLine = true)) {
        secondLine = false;
        startTime = millis();
      }
    }
}
secondLine = false

You are setting secondLine to false rather than testing whether it is true. I assume that you meant to use == rather than =

1 Like

Thank you! That fixed it. Feeling pretty foolish for missing something so obvious.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.