Datasheet

Chapter 2: EEPROM Tricks and Program Tips · Page 59
Building and Testing the LED and Piezospeaker Circuits
The LED and piezospeaker circuit shown in Figure 2-4 is an interesting combination of
the individual circuits. Instead of connecting the LED and piezospeaker to separate I/O
pins, both circuits are connected to the same I/O pin. This circuit can come in handy,
especially if you are running low on available I/O pins. Keep in mind that this circuit
will always light the LED when the speaker plays a tone. Likewise, if the LED is turned
on/off, the speaker will make a clicking sound. The clicking sound when the LED
changes state can actually be useful for "hearing" what's going on with the status
indicator LED during debugging sessions.
Remove all existing circuits from the SumoBot's white breadboard space.
Build the LED circuit shown in Figure 2-4 on the SumoBot's breadboard.
Parts List
(2) Jumper wires
(1) LED - red
(1) Resistor - 470 (yellow-violet-brown)
(1) Piezospeaker
Figure 2-4 Parallel LED and Piezospeaker Circuits
This circuit should be tested to make sure your programs can make the LED turn on/off
as well as make the piezospeaker chime a few notes. In the next example program, you
will see this
PIN directive: