Interrupts and Timers
Interrupts allow microcontrollers to respond to events without having to poll continually to see if anything has changed. In addition to associating interrupts with certain pins you can also use timer-generated interrupts.
As an example of how to use interrupts, let’s revisit digital inputs. The most common way to detect when something has happened at an input (say a switch has been pressed) is to use some code like this:
This code means we continually check inputPin and the moment it reads LOW, we do whatever is specified at the //do something comment. This process works well, but what if you have ...