Datasheet
Light-Sensitive Navigation with Phototransistors • Chapter 6
Robotics with the BOE Shield-Bot • 205
Example Sketch – Light Seeking Display
Make sure the power switch is set to 1.
Create, save, and run the sketch LightSeekingDisplay.
Open the Serial Monitor.
Try casting different levels of shade over the BOE Shield-Bot’s right light sensor.
Does
speedLeft (in the left column) slow down or even go into reverse with lots
of shade?
Try the same thing with the left light sensor to verify the right wheel slows down.
Try casting more shade over both. Again, since the shade is the same for
both,
ndShade should stay close to zero, with little if any slowing of the wheels.
(Remember,
speedLeft and SpeedRight would have to drop by 100 before
they’ll start to slow down.)
/*
* Robotics with the BOE Shield - LightSeekingDisplay
* Displays speedLeft, ndShade, and speedRight in Serial Monitor. Verifies
* that wheel speeds respond correctly to left/right light/shade conditions.
*/
void setup() // Built-in initialization block
{
tone(4, 3000, 1000); // Play tone for 1 second
delay(1000); // Delay to finish tone
About equal light,
full speed forward
ndShade < 0
shade over left
Slow down
speedRight
ndShade > 0
shade over right
Slow down
speedLeft
Back to almost
equal light and
nearly full speed
forward