Project 3: Tilt Blink

For this project, we are building on our 7-Color Blink project from the last chapter with the addition of a simple tilt sensor. Let’s say we want to quickly blink through the seven basic colors when our device is tilted or shaken, but otherwise turn off the LEDs when it’s left alone. The tilt switch we are using to make this happen is a small metal tube with two wires coming out the bottom. Inside is a small metal ball that, when flat makes contact with the two wires closing the switch, but when tilted, the ball rolls away—opening the switch. This will be our way to turn on and off the RGB LED. Alternatively, any number of mechanical switches could be used instead if you can’t find a tilt switch.

Hooking It Up

For this project, ...

Get Beginning Arduino Programming now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.