Control Relay with Timer

Hello,

I want to on relay with push-button and turn off after 15 min, during the 15 min timer if I push the button again realy will not off.

Best Regards,

detect a button press. look for a change from button not pressed to pressed. add a 10 msec delay to debounce after reading button state.

keep track of the relay "state". when button pressed and relay state FALSE, turn relay ON and capture time, msecLst = millis().

When button pressed and relay state ON, turn relay OFF and set state to FALSE.

while relay state is ON, check if current time, millis() - msecLst > 15 mins. when true, turn relay OFF

When button pressed and relay state ON, turn relay OFF and set state to FALSE.

OP actually wants the button ignored if the relay is on, I think:

during the 15 min timer if I push the button again realy will not off.

(In which case, do nothing.)