Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
Questions
Exercises
Projects
/*
* Robotics with the BOE Shield - Chapter 6, Project 1
* Chirp when light is above threshold. Will require updating value of
* threshold & retesting under bright light to get to the right value.
*/
2. Develop an application that makes the BOE Shield-Bot roam and search for
darkness instead of light. This application should utilize the charge transfer
circuits from Building the Photosensitive Eyes.
The solution for this one is to make a copy of LightSeekingShieldBot, and
add one command to the loop function: ndShade = -ndShade. Add it right
before the ifelse statement. Then, instead of indicating shade to turn away
from, it indicates bright light to turn away from. Another approach would be to
use an ndLight calculation that equals tLeft / (tLeft + tRight). You would
have to search/replace ndShade with ndLight in the sketch.
3. Develop an application that makes the BOE Shield-Bot roam toward a
bright incandescent desk lamp in a room where the only other light sources are
fluorescent ceiling lights. The BOE Shield-Bot should be able to roam toward the
desk lamp and play a tone when its under it. This application should use the
charge transfer circuits from Building the Photosensitive Eyes.
Use LightSensorValues to determine a threshold. Its best to take tLeft +
tRight. You can use the LightSensorValues to test this. Start with a value thats
1/4 of the way from reaching the bright light level. So if tLeft + tRight = 4000
and 400 for bright light, use the value 400 + (4000 400) = 400 + 900 =
1300. Dont use 1300, its just an example; figure out the value for your
conditions. Next, add an if statement similar to the one from
HaltUnderBrightLight to the main loop of LightSeekingShieldBot. Careful
though, HaltUnderBrightLight uses the greater than (>) operator because its
using a voltage output circuit. We need the less than (<) operator for the QT
circuit because smaller values mean brighter light. We also need to express the
threshold as a floating point value, like 1300.0. Heres an example:
/*
* Robotics with the BOE Shield - Chapter 6, Project 3
* Roams toward light and away from shade.
*/
// maneuver function
void maneuver(int speedLeft, int speedRight, int msTime)
{
servoLeft.writeMicroseconds(1500 + speedLeft); // Set Left
servo speed
servoRight.writeMicroseconds(1500 - speedRight); // Set right
servo speed
if(msTime==-1) // if msTime =
-1
{
servoLeft.detach(); // Stop servo
signals
servoRight.detach();
}
delay(msTime); // Delay for
msTime
}