Datasheet

Chapter 8 Robot Control with Distance Detection
252Robotics with the BOE Shield-Bot
Displaying Both Distances
It’s important to test that the detection distances are roughly the same for both IR
LED/receiver pairs. They don’t have to be identical, but if they are too far apart, the BOE
Shield-Bot might have difficulty following an object in front of it because it will keep trying to
turn to one side. More subsystem testing!
A common cause of mismatched distance measurement is mismatched resistors used with
the IR LEDs. For example, if one side’s IR LED has a 1 kΩ resistor and the other has a 2
resistor, one side will need objects to be much closer to see them. Another possibility,
though rare, is that one IR detector is far more sensitive than the other. In that case, a larger
resistor can be used in series with the IR LED on that side to make its IR headlight dimmer
and correct the mismatched measurements.
Example Sketch DisplayBothDistances
This screen capture shows some detection zone measurements from DisplayBothDistances
in the Serial Monitor. Though there’s fluctuation in the values, commonly called noise, what
matters is that the numbers match, or are off by only 1, in each pair of measurements.
Create, save, and run the sketch DisplayBothDistances on your Arduino.
Use a box, book, bottle, or similar object as a target for the left distance detector.
Start by moving the object toward and away from the BOE Shield-Bot until you
find the small range where a small movement will result in a change in distance
measurement.
Find and record the midpoint of each distance detection zone.
Repeat for the right IR detector.
Right distances
Left distances