Page 172 · Robotics with the Boe-Bot
How do you get the BASIC Stamp to tell you whether it's reading a 1 or 0? Because
the circuit is connected to P7, this 1 or 0 value will appear in a variable named
called an input register. Input register variables are built-in and do not have to be declared in
the beginning of your program. You can see the value this variable is storing by using the
command
DEBUG BIN1 IN7
display one binary digit (either 1 or 0).
Example Program: TestWhiskers.bs2
This next example program is designed to test the whiskers to make sure they are
functioning properly. By displaying the binary digits stored in the P7 and P5 input
registers (
and
), the program will show you whether the BASIC Stamp detects
IN7
IN5
contact with a whisker. When the value stored in a given input register is 1, the whisker
is not pressed. When it is 0, the whisker is pressed.
√
Reconnect power to your board and servos.
√
Enter, save, and run TestWhiskers.bs2.
√
This program makes use of the Debug Terminal, so leave the serial cable
connected to the BASIC Stamp while the program is running.
' Robotics with the Boe-Bot - TestWhiskers.bs2
' Display what the I/O pins connected to the whiskers sense.
' {$STAMP BS2}
. The
is a formatter that tells the Debug Terminal to
BIN1
' Stamp directive.
.
is
IN7
IN7
Figure 5-8
Detecting Electrical
Contacts
Need help?
Do you have a question about the Boe-Bot and is the answer not in the manual?
Questions and answers