Hello!
I have compiled a code for my central lockign system for my car but the only problem I have was with delay function. When button is pressed I want it to do for example: lock doors, beep once, blink 5 times and close the windows or something like that.
//locking
if (buttonA == HIGH)
{
digitalWrite(relaylock, HIGH);
digitalWrite(relayindicators, HIGH);
digitalWrite(relaybeep, HIGH);
digitalWrite(relaywindowup, HIGH);
delay(150);
digitalWrite(relaysound, LOW);
digitalWrite(relayindicators, LOW);
delay(300);
digitalWrite(relaylock, LOW);
delay(8600);
digitalWrite(relaywindowup, LOW);
}
So as you can see, when button is pressed it does several things and after some time it turns off but the delay is long because this is the time needed for switch/relay to be pressed to close the windows, problem is that I cannot interupt this time with another button (maybe with unlock button beacuse I forgot my phone on the sear) so I have to wait the time to pass. I also have a photoresistor that tells of it is dark then it turns on fog lights for 22 seconds.
How can I interrupt the delay, can I use millis and how?
Thanks!