Go Down

Topic: if else if help with time delay (Read 4163 times) previous topic - next topic


hello :)
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 :)

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

my program :)
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;



Oct 13, 2012, 08:43 pm Last Edit: Oct 13, 2012, 08:45 pm by AWOL Reason: 1
my program

And the rest of it?

Please use code tags when posting code.

Code: [Select]
delay(100);//delay 10 seconds
One of those statements is incorrect.
Guess which one the compiler believes.
"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.
I speak for myself, not Arduino.


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.
The art of getting good answers lies in asking good questions.

Go Up