Please help - Basic car alarm - Delay while wait for button push at same time ?

Trying to build a basic car alarm for my work van. It will work like this:
1.Sense door close and arm
2.Sense door open a wait 5 secs for secret button to be pushed and disarm until next door close.
3.If no secret button push with 5 secs sound alarm 5 mins until secret button pushed or time has elapsed.
in which return to step 1 and wait for door close.

Problem step 2, cant use delay while waiting for secret button push. Obviously won't work.

Can someone steer me in the correct direction? Remember that I am learning. I have been looking at

Do while, blink without delay and for command with a if statement with delay and break.?

A small example to get me going would be appreciated.

Thanks.

Use the millis timer in a loop which checks two things, first has the time expired and second is your button pressed.
Use a while statement to keep the program checking until time is up or the button is pressed.

Hi,
I think you will find there are regulations about how long your alarm is allowed to sound (noise pollution).
Most are 30seconds then re-arm.
But may be different in different countries.
But as Mike says it do able with arduino.

Tom... :slight_smile:

Frankly, rather than a secret button push (which has to be inside the van, I guess) why not use one of the ultracheap 1 to 4 channel remotes from the Far East (the transmitter is even on a keyfob) which would then turn off your alarm without all this waiting stuff.

You can also arm it that way, more reliable than a dodgy interior car light switch (less wiring too).

Those remotes (get one without relays) are very cheap if you can buy from the Far East - see my Youtube video #27 which uses one to control a night light but the principle is identical. Very easy to do with an Arduino. Simples.

Have a look at how millis() is used to manage timing in Several Things at a Time

...R

Thank-you all very much for your replies.

I will look into the keyfob to simply things. Hope to keep things very cheap.