Delaying interrupt execution


My Mega is put to sleep and wakes up using an interrupt via a button. However, I only want the Mega to wake up again if the button is pressed for say 1-2 seconds, instead of instantly.

Is this possible?


You would need to remember when it woke up, and then wait for the button to be released. If the time when it was released is less than (say) 2 seconds, then go back to sleep again.

However don't do this test in the interrupt routine, or you will have trouble recognizing when 2 seconds elapses.

You can make a circuit to delay the button signal. Use a resistor and capacitor for 2 second RC timing. Follow with a Schmitt Trigger to give a sharp risetime for the pin of the Arduino. Design it with a diode so holding down the button charges through the resistor and releasing the button has a path through the diode to quickly restore the other value.