
Parallax, Inc
http://www.parallaxinc.com
http://www.stampsinclass.com
WhiskerKitInstructions(June2000) •Page3
BASICStampBoe-BotNavigationUsingWhiskers
Whiskers.bs2is a simpleroaming program example thatuses Whiskers insteadof infrared for objectdetection.
This program listing makes the Boe-Bot travel straight ahead while monitoring the whiskers to see if they have
bumpedintoanobstacle. Assoonasanobstacleisdetected,theBoe-Botbacksup,turns,andcontinuesforward
untilanotherobstacleisencountered.
When a whisker is pressed,due to anobstacle, the normallyopen switch closes. When thishappens, the output
signalgoesfromhightolow.I/Opins P10 andP5aresetto input andusedtomonitorthe states oftheseswitches.
Thetwowhiskersmaybeinoneoffourstates:
(1) Bothhigh–noobjectsdetected
(2) Leftlow,righthigh–objectdetectedontheleft,turnright.
(3) Rightlow,lefthigh–objectdetectedontheright,turnleft.
(4) Bothlow–indicatesahead-oncollisionwithawideobjectsuchasawall.
' Whiskers.bs2 - Simple program for detecting objects
' with a BASIC Stamp II in a Boe-Bot
' Constant and Variable Definitions
'-----------------------------------------------------------------------------------
servo_left con 15 ' left servo on P15
servo_right con 14 ' right servo on P15
whisker_left var in10 ' left whisker on P10
whisker_right var in5 ' right whisker on P5
counter var word ' loop counter variable
' Main Program
'-----------------------------------------------------------------------------------
check_whiskers: ' check each whisker
if whisker_left = 0 and whisker_right = 0 then back
if whisker_left = 0 then right
if whisker_right = 0 then left
drive_servos: ' drive forward
pulsout servo_left,850
pulsout servo_right,650
pause 10
goto check_whiskers
back: ' backwards if both switches close
for counter = 0 to 100
pulsout servo_left,650
pulsout servo_right,850
next
return
goto drive_servos
left: ' turn left if right switch closes
gosub back
for counter = 0 to 50
pulsout servo_left,650
pulsout servo_right,650
next
goto drive_servos