Page 254 · Robotics with the Boe-Bot
command’s worth of time, the IR detector will return to the not detected (1 state),
regardless of whether or not it detected an object.
FREQOUT 8, 1, 38500
irDetectLeft = IN9
FREQOUT 2, 1, 38500
irDetectRight = IN0
In the IF…THEN statements, instead of delivering pulses or calling navigation routines,
this program sets variable values that will be used in
PULSOUT commands’ Duration
arguments.
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
Before the DO…LOOP repeats, the last thing to do is to deliver pulses to the servos. Notice
that the
PAUSE command is no longer 20. Instead, it’s 15 since roughly 5 ms is taken
checking the IR LEDs.
PULSOUT 13,pulseLeft ' Apply the pulse.
PULSOUT 12,pulseRight
PAUSE 15
Your Turn
√ Save FastIrRoaming.bs2 as FastIrRoamingYourTurn.bs2.
√ Use the LEDs to broadcast that the Boe-Bot has detected an object.
√ Try modifying the values that pulseLeft and pulseRight are set to so that the
Boe-Bot does everything at half speed.