Bells and Whistles

LEDs and piezo speakers create user interface for many embedded devices. Even though they are low-key compared to computer displays and big speakers, they serve an important function. Users expect to get feedback on what they are doing.

Using LEDs and speakers to describe program state also helps coding. It would be difficult to keep a moving robot continuously on a USB leash. Sounds and lights on the robot will tell you what’s happening, so you don’t have to divide your attention between the serial monitor and the device. And of course, you don’t have to fight with a lost serial connection.

Red, Green, and Blue LED

An RGB LED has three LEDs in one package (Figure 2-18). The colors of those LEDs are the primary colors: red, green, and blue (Figure 2-19). When you mix colors by turning on multiple LEDs, you get secondary colors such as cyan, magenta, and yellow.

An RGB LED has three LEDs in one package

Figure 2-18. An RGB LED has three LEDs in one package

RGB LED primary colors

Figure 2-19. RGB LED primary colors

The RGB LED you use in this project has one positive leg and three negative legs. This configuration is called common anode. The positive wire is always connected to Arduino’s +5V.

When your data pins (D9, D10, D11) are at +5V, there is no voltage difference between the LED’s legs. All the LEDs are off.

When you want to light ...

Get Make a Mind-Controlled Arduino Robot now with the O’Reilly learning platform.

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