You are on page 1of 3

Chapter 3 Challenges

Questions
1. What are some of the symptoms of brownout on the BOE Shield-Bot?
the symptoms are unpredictable behaviors like for example going in random directions or
random dancing
2. What is a reset?
when the Arduino restarts to perform a Arduino sketch from the start
3. How can a piezo speaker be used to announce that brownout just occurred?
when you add statements to the piezo speaker that make a tone at the start of your sketches it will
play a tone if brownout occurs
4. What function makes the speaker play tones?
the tone function
5. What’s a hertz? What’s its abbreviation?
it's a measurement of the number times per second a signal repeats itself.
Exercises
1. Write a statement that makes a tone, one that sounds different from the start-alert tone, to
signify the end of a sketch. tone(4, 2000, 1500) ;
2. Write a statement that plays a speaker tone to signify an intermediate step in the sketch.
This tone should be different from a start-alert or end tone tone (4, 4000, 75).

Projects
1. Modify the TestServoSpeed sketch so that it makes a tone signifying each test is
complete*
Robotics with the BOE Shield – Chapter 3, Project 1
*/

#include <Servo.h> // Include servo library

Servo servoLeft; // Declare left servo signal
Servo servoRight; // Declare right servo
signal

void setup() // Built in initialization
block
{
tone(4, 3000, 1000); // Play tone for 1 second
delay(1000); // Delay to finish tone

Serial.begin(9600); // Set data rate to 9600 bps
servoLeft.attach(13); // Attach left signal to P13
}

void loop() // Main loop auto-repeats
{

// Loop counts with pulseWidth from 1375 to 1625 in increments of 25.

servoLeft.writeMicroseconds(pulseWidth). // Delay to finish tone Serial.available() == 0)..attach(13). // Declare right servo signal void setup() // Built in initialization block { tone(4.writeMicroseconds(1500). // Display pulseWidth value Serial.attach(12). for(int pulseWidth = 1375. // Attach left signal to P13 servoRight. // Attach right signal to P12 } .for 6 seconds servoLeft. 4000. /* Robotics with the BOE Shield – Chapter 3...println("Send to start servo..println(pulseWidth). // Pin 13 servo speed = stop tone(4. while(Serial. // .println("Running. // Pin 13 servo speed = pulse delay(6000). pulseWidth += 25) { Serial. // User prompt Serial. Project 2 */ #include <Servo. // Test complete } } . 1000)."). 3000. // Set data rate to 9600 bps servoLeft. // Clear character Serial. Modify the Test Servo Speed sketch so that it runs both wheels instead of just one with each test. // Wait for character Serial. 2. 75).read().begin(9600).print("pulseWidth = "). // Declare left servo signal Servo servoRight. // Play tone for 1 second delay(1000). Make the right wheel turn the opposite direction from the left wheel. pulseWidth <= 1625. Serial.").h> // Include servo library Servo servoLeft.println("Press a key and click")..

println(pulseWidth).. // .void loop() // Main loop auto-repeats { // Loop counts with pulseWidth from 1375 to 1625 in increments of 25. servoRight.writeMicroseconds(1500).available() == 0)..").read(). // User prompt Serial. // Pin 13 servo speed = stop servoRight. // Pin 12 servo speed = stop tone(4.print("pulseWidth = ").writeMicroseconds(1500).writeMicroseconds(1500 + (1500 ."). while(Serial.. // Clear character Serial.. 75). // Wait for character Serial. // Display pulseWidth value Serial.pulseWidth))..for 6 seconds servoLeft. Serial. 4000. // Test complete } } . for(int pulseWidth = 1375. pulseWidth <= 1625.println("Press a key and click"). delay(6000).writeMicroseconds(pulseWidth). // Pin 13 servo speed = pulse // Pin 12 servo opposite direction of pin 13 servo.println("Send to start servo. pulseWidth += 25) { Serial. servoLeft.println("Running.