Daniel Garcia from Protostack has made a good tutorial describing the steps to Understand How to use External Interrupts on an ATmega168. It is nice to forget about manually coding to look for changes in state of inputs and other conditions within the microcontroller. Interrupts allow us to keep on doing real work while the system keep monitoring for changes.
“Microcontroller interrupts are just like that.
- The microcontroller is executing it’s main routine
- An event occurs, which raises an interrupt
- The Interrupt Service Routine (ISR) is run
- On termination of the ISR, the microcontroller returns to it’s main routine, at the point where it left off”