Datasheet

Chapter 7 Navigating with Infrared Headlights
224Robotics with the BOE Shield-Bot
Place an object, such as your hand or a sheet of paper, about an inch (2 to 3 cm)
from the left IR object detector.
Verify that the Serial Monitor displays a 0 when you place an object in front of the
IR object detector, and a 1 when you remove the object.
If the Serial Monitor displays the expected values, go ahead and test the right IR
Object Detector (below). If not, go to the Troubleshooting section for help.
Your Turn Test the Right IR Object Detector
Modifying the sketch to test the right IR object detector is a matter of replacing irLeft
with
irRight, and passing the correct pin numbers to the irDetect parameters to test the
other circuit. Here’s a checklist of the changes:
Save the sketch TestLeftIr as TestRightIr.
Change
pinMode(10, INPUT); pinMode(9, OUTPUT) to pinMode(3,
INPUT); pinMode(2, OUTPUT)
.
Change
int irLeft = irDetect(9, 10, 38000) to int irRight =
irDetect(2, 3, 38000)
.
Change
Serial.println(irLeft) to Serial.println(irRight).
Repeat the testing steps in this activity for the BOE Shield-Bot’s right IR object
detector.
If necessary, trouble-shoot any circuit or code entry errors.
Activity 2: Field Testing
In this activity, you will build and test indicator LEDs that will tell you if an object is detected
without the help of the Serial Monitor. This is handy if you are not near your computer, and
you need to troubleshoot your IR detector circuits.
You will also write a sketch to “sniff” for infrared interference from fluorescent lights. Some
fluorescent lights send signals that resemble the signal sent by your infrared LEDs. The
device inside a fluorescent light fixture that controls voltage for the lamp is called the ballast.
Some ballasts operate in the same frequency range of your IR detector, causing the lamp to
emit a 38.5 kHz infrared signal. When using IR object detection for navigation, ballast
interference can cause some bizarre BOE Shield-Bot behavior!
Adding LED Indicator Circuits
LED indicator circuits are similar to the ones you used with the whiskers. Make sure to be
careful about your cathodes and anodes when you connect them.