I am working on timer interrupts and external interrupts. for external interrupts I understood the functions like attachInterrupt. detachinterrupt for individual interrupts ,noInterrupts() and interrupts() can be used to enable and disable all interrupts at a time.
But How to enable and disable timer interrupts??
I am writing a code for alarm clock and snooze button. So what I want is 1) whenever alarm time is equal to watch time, start a timer for 5 minutes and a buzzer buzzes. 2) whenever I press the snooze button, another timer starts and after 30 seconds a buzzer beeps. again I press snooze and again the timer starts and after 30 seconds buzzer beeps. 3) But after 5 minutes of the first timer, both timer interrupts gets disabled as now I dont want any buzzer.
I know how to initialize the timer in setup function, and I am getting the buzzes every 30 seconds. I also know that interrupts will come according to the timer value and I need to call the function after a fix number of counts or 30 seconds or 5 minutes.
But I dont know how to disable and enable timer interrupts wherever I want in code.
millis()
) seems more appropriate, as you cannot program a hardware timer to fire more than about 4.2 seconds into the future.