Published on May 15, 2014
Detect when a button changes from off to on and on to off.
*To complete this exercise, you will need to download the Arduino software.
This sketch turns a momentary switch (like the button) into a toggle switch, just like the latch module does. This means that every time the button is pressed it will hold its state either on or off. This change of state (on to off/off to on) is detected by the Arduino and recorded, allowing you you to keep track of the number of times the button in pressed (in the serial monitor). This is called a state change detection, or edge detection.
For more “getting started” sketches, click here.
To learn more about coding, find examples on Arduino’s website.