Page 265 - The Ultimate Palm Robot
P. 265
Color profile: Generic CMYK printer profile
Composite Default screen
Bots / The Ultimate Palm Robot/ Mukhar & Johnson / 222880-6 / Chapter 9
248 The Ultimate Palm Robot
LEDs
The first output project we will look at is an extremely simple one. Light
Emitting Diodes, or LEDs, can be directly attached to either the SV203 or the
BrainStem. (Now these are not exactly the same as death ray lasers, but if you
squint your eyes a little, you can pretend they are almost the same.)
We started by connecting an LED to the analog output ports of the SV203
and the BrainStem controller. Later in this chapter, in the section “Using Digital
Components with the BrainStem,” we’ll connect the LEDs to the digital output
ports of the BrainStem.
We used simple colored LEDs available from various sources. The ones we
used are from Radio Shack, part numbers 276-022 and 276-041.
LEDs have two leads—one known as the anode and one known as the cathode.
If you look at the LEDs, you’ll see that one lead is shorter than the other. The
shorterleadisthecathodeandthelongerleadistheanode.Theanodeisattached
to the signal, or Vo, line. On both the SV203 and the BrainStem, this is the pin
farthest from the edge of the board. The cathode is attached to the GND line of
the controller. For both the SV203 and BrainStem, this is the pin closest to the
edge of the board.
Anode
Cathode
Using the programming we saw in Chapter 7 and Chapter 8, we can drive
the LEDs so that they light up on command. With the SV203, we will use the
SVn Mn command. Recall that the SVn command is used to select an output
port; the Mn command sets the output port to a particular value from 0 to 255.
The value 255 will cause the LED to light. For example, this line of BASIC code
will cause an LED connected to output port 4 to light:
print #5, "SV4M255"
P:\010Comp\Bots\880-6\ch09.vp
Monday, May 12, 2003 4:33:45 PM