Datasheet

Page 86· Applied Robotics with the SumoBot
' -----[ Main Routine ]------------------------------------------------
DO ' DO...LOOP repeats indefinitely
irLF = ~IrSenseLF ' Save IR receiver outputs
irRF = ~IrSenseRF
' Sound alarm if IR detected
IF irLF = 1 OR irRF = 1 THEN
DEBUG "IR interference detected!!!", CR
FOR counter = 1 TO 7
FREQOUT LedSpeaker, 50, 4000
PAUSE 50
NEXT
ENDIF
LOOP ' Repeat DO...LOOP
The modified Main Routine also necessitates a few smaller changes, like a PIN
declaration for
LedSpeaker as well as a counter variable for sending a series of rapid
alarm beeps. The Initialization message in the next example program is also changed, as
are the comments at the beginning of the program.
Example Program: IrInterferenceSniffer.bs2
IrInterferenceSniffer.bs2 sounds the SumoBot's piezospeaker alarm whenever it receives
infrared signals in the neighborhood of 38.5 kHz. This could be from another SumoBot,
a handheld remote that controls a TV, a video recorder, or fluorescent lights with an
interfering ballast.
Make sure one of your SumoBots is running TestFrontIrObjectDetectors.bs2.
Disconnect that first SumoBot from the serial cable and set it aside.
Enter and save run IrInterferenceSniffer.bs2.
Download it to the second SumoBot.
Point the first SumoBot's IR LED headlights at the second SumoBot. The
second SumoBot's alarm should sound indicating it has detected IR interference.
Point the first SumoBot away from the second SumoBot, and the alarm should
stop.
Try walking under various fluorescent lights while pointing the second SumoBot
(running IrInterferenceSniffer.bs2) at them. Does its alarm sound? If not, that's
good. If yes, you'll want to keep your SumoBot Competition Ring well away
from those lights, or turn them off.