Commands for both condition2 and condition1
ELSE
Commands for condition1 but not condition2
ENDIF
ELSE
Commands for not condition1
ENDIF
There is an example of nested
alternate whisker contacts in the next program.
Example Program: EscapingCorners.bs2
This program will cause your Boe-Bot to execute a U-turn at either the fourth or fifth
alternate corner, depending on which whisker was pressed first.
√
Enter, save, and run EscapingCorners.bs2.
√
Test this program by pressing alternate whiskers as the Boe-Bot roams.
Depending on which Whisker you started with, the Boe-Bot should execute its
U-Turn maneuver after either the fourth or fifth consecutive whisker press.
' -----[ Title ]--------------------------------------------------------------
' Robotics with the Boe-Bot - EscapingCorners.bs2
' Boe-Bot navigates out of corners by detecting alternating whisker presses.
' {$STAMP BS2}
' {$PBASIC 2.5}
DEBUG "Program Running!"
' -----[ Variables ]----------------------------------------------------------
pulseCount
VAR
counter
VAR
old7
VAR
old5
VAR
' -----[ Initialization ]-----------------------------------------------------
FREQOUT 4, 2000, 3000
counter = 1
old7 = 0
old5 = 1
' -----[ Main Routine ]-------------------------------------------------------
Chapter 5: Tactile Navigation with Whiskers · Page 183
statements in the routine that detects consecutive
IF...THEN
Byte
Nib
Bit
Bit
' Stamp directive.
' PBASIC directive.
' FOR...NEXT loop counter.
' Counts alternate contacts.
' Stores previous IN7.
' Stores previous IN5.
' Signal program start/reset.
' Start alternate corner count.
' Make up old values.
Need help?
Do you have a question about the Boe-Bot and is the answer not in the manual?
Questions and answers