Parallax Boe-Bot Student Manual page 279

Hide thumbs Also See for Boe-Bot:
Table of Contents

Advertisement

' -----[ Main Routine ]------------------------------------------------
Main:
' Loop until something is detected
DO
GOSUB Check_IRs
LOOP UNTIL (irDetectLeft = 0) OR (irDetectRight = 0)
' Now start roaming -- this code from FastIrRoaming.bs2
DO
IF (irDetectLeft = 0) AND (irDetectRight = 0) THEN
pulseLeft = 650
pulseRight = 850
ELSEIF (irDetectLeft = 0) THEN
pulseLeft = 850
pulseRight = 850
ELSEIF (irDetectRight = 0) THEN
pulseLeft = 650
pulseRight = 650
ELSE
pulseLeft = 850
pulseRight = 650
ENDIF
PULSOUT 13, pulseLeft
PULSOUT 12, pulseRight
PAUSE 15
GOSUB Check_IRs
LOOP
' -----[ Subroutines ] ------------------------------------------------
Check_IRs:
FREQOUT 8, 1, 38500
irDetectLeft = IN9
FREQOUT 2, 1, 38500
IrDetectRight = IN0
RETURN
P2. This behavior is in many ways the opposite of the roaming behavior covered in
this chapter. Instead of avoiding objects, the Boe-Bot tries to go toward the
objects.
For this reason, the main code can be derived from
"FastIrRoaming.bs2", with a bit added that spins the Boe-Bot slowly until an
object is detected.
In the solution below, once the Boe-Bot has spied an object, it will continue
forward even if the detectors both read "no object" (1) for a few loops. This is
because, as the Boe-Bot is maneuvering toward the object, sometimes the
Chapter 7: Navigating with Infrared Headlights · Page 265
' Both detect
' Back up
' Left detect
' Turn right
' Right detect
' Turn left
' Nothing detected
' Go forward
' Apply the pulse.
' Check IRs again
' Check IR Detectors

Advertisement

Table of Contents
loading

Table of Contents