if else if help with time delay

hello :slight_smile:
i have a problem on my program, what i want is when i press the button the if statement execute then after 10 seconds the else if statement execute but before the 10 seconds time when i repress the button, if statement execute then the timer count again 10sec.
thanks :slight_smile:

sample video that i want when he didn’t trigger the sensor after a few sencond the lights off :))

my program :slight_smile:
void loop() {

if(digitalRead(switchPin) == HIGH && button == 0){ /* if D2 is HIGH /
delay(200); /
Soft Debounce delay for 500mS */

button = 1;

send(0x0001);//play file 0000
delay(100);//delay 10 seconds

send(0xfff7);//set voice volumn to 7


send(0xfffe);// pause

else if(digitalRead(switchPin) == LOW && button == 1){
button = 0;




my program

And the rest of it?

Please use code tags when posting code.

delay(100);//delay 10 seconds

One of those statements is incorrect. Guess which one the compiler believes.

It would be beneficial to pay some attention to the blink without delay example, and learn to NOT use delay(). If you get rid of the delay()s, then what you want to accomplish is trivial. Resetting the start time effectively changes the end time, making stopping at the right time a no-brainer.