Page 268 ·
Robotics with the Boe-Bot
' -----[ Subroutines ] ------------------------------------------------
Sniff: ' From IrInterferenceSniffer.bs2
IF (IN0 = 0) OR (IN9 = 0) THEN
FOR counter = 1 TO 5 ' Beep 5 times
HIGH 1 ' and flash LEDs
HIGH 10
FREQOUT 4, 50, 4000
LOW 1
LOW 10
PAUSE 20
NEXT
ENDIF
RETURN
Roam: ' From FastIrRoaming.bs2
FREQOUT 8, 1, 38500 ' Check IR Detectors
irDetectLeft = IN9
FREQOUT 2, 1, 38500
irDetectRight = IN0
' Decide how to navigate.
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 ' Apply the pulse.
PULSOUT 12,pulseRight
PAUSE 15
RETURN