I'm trying to make a timer, and I've set one button as reset button, the other one button as starting the timer. Below you can see some parts of the code that I have now:
if ( buttonCount == 0 ) {
t = 180; // 3 mins
display.clearLine(2);
int min = t / 60;
int sec = t % 60;
sprintf(buf, "%02d:%02d", min, sec);
display.draw2x2String(2, 3, buf);
}
// reset button
if ( deBouncerR.fell() ) {
buttonCount = 0;
}
// countdown button
If (deBouncerT.fell() ) {
while (t > 0){
delay(1000);
t = t - 1;
display.clearLine(2);
int min = t / 60;
int sec = t % 60;
sprintf(buf, "%02d:%02d", min, sec);
display.draw2x2String(2, 3, buf);
}
}
So here, the time is set in 3 minutes, and once I press the countdown button, other buttons are not working because of while(). I would like to know how to make reset button to break while loop.