√
Try letting the Boe-Bot roam. When it contacts obstacles in its path, it should
back up, turn, and then roam in a new direction.
' -----[ Title ]--------------------------------------------------------------
' Robotics with the Boe-Bot - RoamingWithWhiskers.bs2
' Boe-Bot uses whiskers to detect objects, and navigates around them.
' {$STAMP BS2}
' {$PBASIC 2.5}
DEBUG "Program Running!"
' -----[ Variables ]----------------------------------------------------------
pulseCount
VAR
' -----[ Initialization ]-----------------------------------------------------
FREQOUT 4, 2000, 3000
' -----[ Main Routine ]-------------------------------------------------------
DO
IF (IN5
= 0) AND (IN7 = 0) THEN
GOSUB Back_Up
GOSUB Turn_Left
GOSUB Turn_Left
ELSEIF (IN5
= 0) THEN
GOSUB Back_Up
GOSUB Turn_Right
ELSEIF (IN7
= 0) THEN
GOSUB Back_Up
GOSUB Turn_Left
ELSE
GOSUB Forward_Pulse
ENDIF
LOOP
' -----[ Subroutines ]--------------------------------------------------------
Forward_Pulse:
PULSOUT 13,850
PULSOUT 12,650
PAUSE 20
RETURN
Turn_Left:
FOR pulseCount = 0 TO 20
PULSOUT 13, 650
PULSOUT 12, 650
Chapter 5: Tactile Navigation with Whiskers · Page 179
Byte
' Stamp directive.
' PBASIC directive.
' FOR...NEXT loop counter.
' Signal program start/reset.
' Both whiskers detect obstacle
' Back up & U-turn (left twice)
' Left whisker contacts
' Back up & turn right
' Right whisker contacts
' Back up & turn left
' Both whiskers 1, no contacts
' Apply a forward pulse
' and check again
' Send a single forward pulse.
' Left turn, about 90-degrees.
Need help?
Do you have a question about the Boe-Bot and is the answer not in the manual?
Questions and answers