I'm a beginner into Arduino so I have a little problem where I'm trying to do a countdown on LCD using while loop but I'm also trying to get a key input inside that same while loop. Problem is that its hard to get a input in that while because there are delay because of timer. Tried to look around the internet for solution but didn't find one. If anybody got a good solution I would be great full if you post it :) Thanks again!
Here is my code:
while (gameInProgress) {
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("Until boom! ");
lcd.print(timer);
lcd.setCursor(0, 1);
lcd.print(passwordInputed);
char key = keypad.getKey();
if (key && gameInProgress) {
passwordInputed += key;
}
analogWrite(buzzerPin, 145);
delay(200);
analogWrite(buzzerPin, 0);
delay(800);
timer--;
if (timer == 0){
gameInProgress = false;
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("Boom happend!");
lcd.setCursor(0, 1);
lcd.print("You lost :(");
}
}