An interrupt is a signal that tells the processor to immediately stop what it is doing and handle some high priority processing. That high priority processing is called an Interrupt Handler.
An interrupt handler is like any other void function. If you write one and attach it to an interrupt, it will get called whenever that interrupt signal is triggered. When you return from the interrupt handler, the processor goes back to continue what it was doing before.
Where do they come from?
Interrupts can be generated from several sources:
- Timer interrupts from one of the Arduino timers.
- External Interrupts from a change in state of one of the external interrupt pins.
- Pin-change interrupts from a change in state of any one of a group of pins.
What are they good for?
Using interrupts, you don’t need to write loop code to continuously check for the high priority interrupt condition. You don't have to worry about sluggish response or missed button presses due to long-running subroutines.
The processor will automagically stop whatever it is doing when the interrupt occurs and call your interrupt handler. You just need to write code to respond to the interrupt whenever it happens.