Page 234 · Robotics with the Boe-Bot
' Both detect black paper, back up and make a noise
IF (timeLeft > LeftAvg) AND (timeRight > RightAvg) THEN
PULSOUT 13, 650
PULSOUT 12, 850
FREQOUT 4, 20, 4400
' Left detects black paper, turn away to right, make a noise
ELSEIF (timeLeft > LeftAvg) THEN
PULSOUT 13, 850
PULSOUT 12, 850
FREQOUT 4, 20, 2200
' Right detects black paper, turn away to left, make a noise
ELSEIF (timeRight > RightAvg) THEN
PULSOUT 13, 650
PULSOUT 12, 650
FREQOUT 4, 20, 3300
' Neither detects black paper, go forward one pulse.
ELSE
PULSOUT 13,850
PULSOUT 12,650
PAUSE 20
ENDIF
RETURN
Hints: Make sure to test and understand what the Boe-Bot sees when it is
focused on a black sheet of paper and what it sees when it is focused on a white
background. Use example programs from the last three activities in this chapter.
The RC decay time circuit and programs will be much more helpful for making
the program work than the photoresistor divider techniques. Also, make sure this
obstacle course is in a uniformly lit area. Bright sunlight from windows, and
shadows cast by onlookers can make the demonstration fail.
P2. The "AvoidBlackSpots.bs2" program solution, above, works quite well to keep
the Boe-Bot confined in a black-bordered space. A video clip of a Boe-Bot
doing just this can be viewed at www.parallax.com. Under the Robotics menu,
look for Robo Video Gallery.
' Beep instead of pause
Need help?
Do you have a question about the Boe-Bot and is the answer not in the manual?
Questions and answers