Interrupts are weird things in the Arduino world; however, they are immensely useful. So what are they? Interrupts signal to the microcontroller that something has happened and it needs to take some action. Basically they work like this: we can attach an interrupt to a digital pin. Whenever it detects a change, it will pause anything the microcontroller is doing, execute a function we tell it to execute, and then resume normal operation.
In this example, we will fade two LEDs using PWM and while that is happening, we will be able to select which LED is fading using the button connected to an interrupt.
Following are the ingredients needed for this recipe:
- An Arduino board connected to a computer via USB
- Jumper cables ...