Datasheet

Chapter 7 Navigating with Infrared Headlights
232Robotics with the BOE Shield-Bot
Replace the 2 kΩ resistors that connect pin 2 and pin 9 to the IR LED anodes with
4.7 kΩ resistors.
Determine the furthest distance at which the same sheet of paper is detected, and
record your data.
Repeat with 1 kΩ resistors, 470 Ω resistors, and 220 Ω resistors. (For the smaller
resistor values, they may end up making the detectors so sensitive that they see
the table surface in front of your robot. If that happens, set the robot on the edge
of the table with the IR detectors pointing off the end and try the distance
measurements again.)
Detection Distances vs. Resistance
IRELD Series Resistance (Ω)
Maximum Detection Distance
4700
2000
1000
470
220
Before moving on to the next activity, restore your IR object detectors to their
original circuit, with 2 kΩ resistors in series with each IR LED.
Also, before moving on, make sure to test this last change with
TestBothIrAndIndicators to verify that both IR object detectors are working
properly.
Activity 4: Object Detection and Avoidance
An interesting thing about these IR detectors is that their outputs are just like the whiskers.
When no object is detected, the output is high; when an object is detected, the output is low.
In this activity, the example sketch RoamingWithWhiskers is modified so that it works with
the IR detectors; all it takes is few simple modifications. Here are the steps:
1. Save the sketch RoamingWithWhiskers as RoamingWithIr
2. Add the
irDetect function.
int irDetect(int irLedPin, int irReceiverPin, long frequency)
{
tone(irLedPin, frequency, 8);
delay(1);
int ir = digitalRead(irReceiverPin);
delay(1);