Datasheet

Page 62· Applied Robotics with the SumoBot
Parts List
(1) Jumper wire
(1) LED - red
(1) 1 Resistor - 470 (yellow-violet-brown)
(1) 1 Resistor - 10 k (brown-black-orange)
Figure 2-5 Pushbutton Circuit added to LED and Piezospeaker
A
PIN directive can also be used for P6:
pBSense PIN 6
Now the name pBSense can be used in DEBUG commands to display whichever
pushbutton state the I/O pin senses.
pBSense can also be used in IF...THEN and other
conditional statements that might need to make decisions based on the state of the
pushbutton. In other words, you can use
DEBUG BIN1 pbSense or IF pbSense = ...
just as you would use
DEBUG BIN1 IN6 and IF IN6 = ... Either way, the decision is
actually made based on the value stored in the BASIC Stamps
IN6 input register, which
is where the 1 or 0 sensed by the I/O pin is actually stored. Nonetheless, using a
PIN
symbol like
pbSense just makes programs more convenient to write and easier to read.
The next example program should display a series of zeros while the pushbutton on the
breadboard is not pressed, and a series of ones while it is pressed. Figure 2-6 shows an
example.