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 IN7. IN7 is
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. The BIN1 is a formatter that tells the Debug Terminal to
display one binary digit (either 1 or 0).
Figure 5-8
Detecting Electrical
Contacts
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 (
IN7 and IN5), the program will show you whether the BASIC Stamp detects
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} ' Stamp directive.