Hi all, I am doing a project in which I am making a lock. The lock unlocks via keypad, and I want to have different things going on once it is unlocked. I would like to give the user the option to press the D key on the keypad to re-lock it, however if it is not re-locked in 5 minutes set off an alarm (piezo speaker). I cannot do this with a delay, because there is not enough time for the user to react and press the D key. How would I put this action on a timer, so that the timer can be counting without stopping the entire code?
google the time library!
Use this for your timer, it works for me just fine!
void loop(){
Serial.print("Time: ");
time = millis();
//prints time since program started
Serial.println(time);
// wait a second so as not to send massive amounts of data
delay(1000);
}
How would I put this action on a timer, so that the timer can be counting without stopping the entire code?
The hardware timers do not have much of a capacity, you use the millis function to return the current time, like in the blink without delay example in the IDE.