irDetectRight
VAR
pulseLeft
VAR
pulseRight
VAR
FREQOUT 4, 2000, 3000
DO
FREQOUT 8, 1, 38500
irDetectLeft = IN9
FREQOUT 2, 1, 38500
irDetectRight = IN0
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
LOOP
How FastIrRoaming.bs2 Works
This program takes a slightly different approach to applying pulses. Aside from the two
bits used to store the IR detector outputs, it uses two word variables to set the pulse
durations delivered by the
irDetectLeft
irDetectRight
pulseLeft
pulseRight
Inside the
, the
DO...LOOP
each IR LED. Immediately after the 1 ms burst of IR is sent, a bit variable stores the
output state of the IR detector. This is necessary, because if you wait any longer than a
Chapter 7: Navigating with Infrared Headlights · Page 253
Bit
Word
Word
command.
PULSOUT
VAR
Bit
VAR
Bit
VAR
Word
VAR
Word
commands are used to send a 38.5 kHz IR signal to
FREQOUT
' Signal program start/reset.
' Main Routine
' Check IR Detectors
' Decide how to navigate.
' Apply the pulse.
' Repeat main routine
Need help?
Do you have a question about the Boe-Bot and is the answer not in the manual?
Questions and answers