Using the classic 'blink without delay' as a starting point, you get this:
unsigned long nextMillis = millis() + timer;
for (int count = 10; count > -1; count--) {
while(millis() < nextMillis) {
if(/* button is pressed */) {
//maybe do some debouncing here?
mode = 0; //go back to standby mode
return;
}
}
nextMillis = millis() + timer;
lcd.setCursor(0,1);
lcd.print(count);
lcd.print(" Seconds...");
}
mode = 2;
Thanks Tom,
That looks great, looking forward to testing it when I get back to the hardware.
Not sure what you mean by debouncing however...
If I was to implement this in my case, would it look something like this?
unsigned long nextMillis = millis() + timer;
for (int count = 10; count > -1; count--) {
while(millis() < nextMillis) {
if(digitalRead(armButton) == HIGH) {
//maybe do some debouncing here?
mode = 0; //go back to standby mode
return;
}
}
nextMillis = millis() + timer;
lcd.begin(16,2);
lcd.print("System Arming in");
lcd.setCursor(0,1);
lcd.print(count);
lcd.print(" Seconds...");
}
mode = 2;
Also not sure what you mean by "blink without delay".
Again, apologies for my ignorance and thank you for you patience. This is my first introduction to C and my first micro-controller project!