LCD print arrays of Strings with millis();

PaulS:

  int i = 0;

if (currentLCDMillis - previousLCDMillis > interval2) {
    i++;
    lcd.setCursor (6, 0);
    lcd.print("      ");          //delete the old text
    lcd.setCursor (6, 0);
    lcd.print(languages[i]);



The first time that languages is accessed, i=1. You don't want to increment i until AFTER it has been used the first time.

Since that function is called over and over, it seems likely that i should be static.

And, i is a crappy name for a static variable.

Thanks, it works better now. Only problem - it does not delete old text. Tried writing spaces on top and use lcd.clear();

I hate the name i also, but isn't it a default name for variables that being incremented?

void kalba() {
  //function telling users they should select the language
  //four languages should switch between with the delay of 2 sec.

  unsigned long currentLCDMillis = millis(); //check current time
  unsigned long  interval2 = 2000;
  static unsigned long previousLCDMillis = 0; //set first old time to 0


  String languages[4] = {"Kalba?", "Language?", "Runa?", "Y3Ik?"};
  int langCycle = 0; //cycle is 0, it is used and waits for millis to hit 2000
  if (currentLCDMillis - previousLCDMillis > interval2) {
    langCycle++;
    lcd.setCursor (6, 0);
    lcd.print("       ");         //delete the old text - DOES NOT WORK
    previousLCDMillis = currentLCDMillis;
  }
  lcd.setCursor (6, 0);
  lcd.print(languages[langCycle]);
  if (langCycle == 3) {
    langCycle = 0;
  }
}