Page 216 · Robotics with the Boe-Bot
FREQOUT 4, 2000, 3000
' -----[ Main Routine ]-------------------------------------------------------
DO
GOSUB Test_Photoresistors
GOSUB Navigate
LOOP
' -----[ Subroutine - Test_Photoresistors ]-----------------------------------
Test_Photoresistors:
HIGH 6
PAUSE 3
RCTIME 6,1,timeLeft
HIGH 3
PAUSE 3
RCTIME 3,1,timeRight
RETURN
' -----[ Subroutine - Navigate ]----------------------------------------------
Navigate:
IF (timeLeft < LeftThreshold) AND (timeRight < RightThreshold) THEN
PULSOUT 13, 850
PULSOUT 12, 650
ELSEIF (timeLeft < LeftThreshold) THEN
PULSOUT 13, 700
PULSOUT 12, 700
ELSEIF (timeRight < RightThreshold) THEN
PULSOUT 13, 800
PULSOUT 12, 800
ELSE
PULSOUT 13, 750
PULSOUT 12, 750
ENDIF
PAUSE 20
RETURN
' Left RC time measurement.
' Right RC time measurement.
' Both detect flashlight beam,
' full speed forward.
' Left detects flashlight beam,
' pivot left.
' Right detects flashlight beam,
' pivot right.
' No flashlight beam, sit still.
' Pause between pulses.
Need help?
Do you have a question about the Boe-Bot and is the answer not in the manual?
Questions and answers