Datasheet

Navigating with Infrared Headlights • Chapter 7
Robotics with the BOE Shield-Bot 245
Projects
1. Design a BOE Shield-Bot application that sits still until you wave your hand in
front of it, then it starts roaming.
2. Design a BOE Shield-Bot application that slowly rotates in place until it detects an
object. As soon as it detects an object, it locks onto and chases the object. This is
a classic ‘SumoBot’ behavior.
3. Design a BOE Shield-Bot application that roams, but if it detects infrared
interference, it sounds the alarm briefly, and then continues roaming. This alarm
should be different from the low battery alarm.
Question Solutions
1. 38 kHz is the frequency of the signal. Although the 8 in tone call’s ms parameter
calls for a signal that lasts for 8 ms, the book said that testing indicated it lasted
for 1.1 ms. The IR LED must be connected to the digital pin 8 socket for the tone
signal to make it flash on/off at 38 kHz.
2. The code has to pause for 1 ms with
delay(1) and then store the IR value by
copying whatever
digitalRead returns to a variable; for example, delay(1)
followed by
irLeft = digitalRead(10).
3. A low signal means that 38 kHz IR was detected, which means that the 38 kHz
flashing light the IR LED transmitted must have reflected off an object in its path.
In other words: object detected. A high signal means no 38 kHz IR was detected,
so, there wasn’t any object to reflect the IR LED’s light. In other words: object not
detected.
4. For both red and infrared LEDs, a smaller resistor will cause the LED to glow
more brightly. A larger resistor results in dimmer LEDs. In terms of results,
brighter IR LEDs make it possible to detect objects that are farther away. But it
can also have annoying side effects, like seeing the reflection of the surface it is
rolling on and misinterpreting it as an obstacle.
Exercise Solutions
1. Let’s remove the left IR detector from the code. Comment out int irLeft =
digitalRead(10) by placing // to its left. Then, change if((irLeft == 0) ||
(irRight == 0))
to if(irRight == 0).
2. Remember that linear wheel speed control is in the -100 to 100 range. So -75
should be a little slower than full speed backward. With that in mind, try
changing
maneuver(-200, -200, 250) to maneuver(-75, -200, 250).