Page 190 ยท Robotics with the Boe-Bot
Solutions
Q1. A tactile switch.
Q2. Zero (0) volts, resulting in Binary zero (0) at the input register.
IN8 = 0 when whisker is pressed. IN8 = 1 when whisker is not pressed.
Q3. IN7 = 1 means the right whisker is not pressed.
IN7 = 0 means the right whisker is pressed.
IN5 = 1 means the left whisker is not pressed.
IN5 = 0 means the left whisker is pressed.
Q4. The
GOSUB command performs the actual jump. The IF...THEN command is used
to decide which subroutine to jump to. That decision is based on conditions,
which are logical statements that evaluate to true or false.
Q5. The program can check for one condition, and if that condition is true, it can
check for another condition within the first condition.
E1. The key to solving this problem is to use a second
CRSRXY command that will
place the right whisker state in the proper place on the screen. To line up with
the headings, the text should start on column 9 of row 3.
' Robotics with the Boe-Bot - TestWhiskers_UpdateEaOnNewLine.bs2
' Update each whisker state on a new line.
' {$STAMP BS2} ' Stamp directive.
' {$PBASIC 2.5} ' PBASIC directive.
DEBUG "WHISKER STATES", CR,
"Left Right", CR,
"------ ------"
DO
DEBUG CRSRXY, 0, 3, "P5 = ", BIN1 IN5 ' Print in Column 0,Row 3
DEBUG CRSRXY, 9, 3, "P7 = ", BIN1 IN7 ' Print in Column 9,Row 3
PAUSE 250 ' Change from 50 to 250
LOOP
E2.
Turn_Away:
GOSUB Back_Up
GOSUB Turn_Left
GOSUB Turn_Left
RETURN