UKHeliBob:
Again, before running it can you predict what it will print ?
I would guess first sketch will print millis() and the second - a bunch of zeros?
[after running it] WRONG, other way around.
Yes, now I have no global, seems now everything is working fine.
I will need some custom characters, since this LCD does not support cyrillic alphabet.
code without global:
#include <Wire.h>
#include <LiquidCrystal.h> // includes the LiquidCrystal Library
LiquidCrystal lcd(32, 30, 28, 26, 24, 22);
//LiquidCrystal lcd_name(rs, en, d4, d5, d6, d7);
void setup() {
//My LCD was 16x2
lcd.begin (16, 2);
lcd.home(); // go home
Serial.begin(9600);
}
void loop() {
//bunch of other stuff here
kalba();
}
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?", "Yazyk?"};
static 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 == 4) {
langCycle = 0;
}
}