FREQOUT 4, 2000, 3000
' -----[ Main Routine ]-------------------------------------------------------
DO
FREQOUT 8, 1, 38500
irDetectLeft = IN9
FREQOUT 2, 1, 38500
irDetectRight = IN0
IF (irDetectLeft = 0) AND (irDetectRight = 0) THEN
GOSUB Back_Up
GOSUB Turn_Left
GOSUB Turn_Left
ELSEIF (irDetectLeft = 0) THEN
GOSUB Back_Up
GOSUB Turn_Right
ELSEIF (irDetectRight = 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
PAUSE 20
NEXT
RETURN
Turn_Right:
FOR pulseCount = 0 TO 20
PULSOUT 13, 850
PULSOUT 12, 850
PAUSE 20
NEXT
RETURN
Chapter 7: Navigating with Infrared Headlights · Page 251
' Signal program start/reset.
' Store IR detection values in
' bit variables.
' Both IR pairs detect obstacle
' Back up & U-turn (left twice)
' Left IR pair detects
' Back up & turn right
' Right IR pair detects
' Back up & turn left
' Both IR pairs 1, no detects
' Apply a forward pulse
' and check again
' Send a single forward pulse.
' Left turn, about 90-degrees.
' Right 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