I want two blocks of text to be displayed every 2 seconds. However, when I try running the code, just the second block is displayed.
Here is the code:
unsigned long previousTime = 0;
unsigned long previousTime2 = 0;
const long intervalTime = 2000;
void loop() {
customKey = customKeypad.getKey();
if (customKey) {
tone(buzzer, 1000, 100); //activate buzzer, keys sound when presssed
}
unsigned long currentTime = millis();
while (customKey == NO_KEY) {
if (currentTime - previousTime > intervalTime) {
previousTime = currentTime;
// display first block of text.
}
unsigned long currentTime2 = millis();
if(currentTime2 - previousTime2 > intervalTime) {
// display second block of text
}
switch(customKey) {
case 'A':
lcd.print("");
break;
}
}
}