Skip to content
Parallax Learn

Parallax Learn

  • Welcome
  • Tutorials
        • Tutorial Series head tag

          Tutorial Series
        • Tutorial Series

          The special, classroom-ready series pages are organized collections of tutorials for our most popular hardware and/or languages. The tutorials for each topic are conveniently accessible from a single page, shown in the order it is recommended that they be completed.
        • Robotics Series Head tag

          Robotics Series
        • Robotics Series

          • Artificial Intelligence
          • Cybersecurity: Radio Data tutorialCybersecurity
          • cyber:bot + Python
          • cyber:bot + MakeCode
          • Boe-Bot Tutorial SeriesBoe-Bot
          • Arduino Shield-Bot
          • ActivityBot with C TutorialsActivityBot + C
          • ActivityBot with BlocklyProp Tutorial SeriesActivityBot + BlocklyProp
          • Scribbler 3 Tutorial SeriesScribbler 3
        • Electronics & Programming Series Head tag

          Electronics & Programming Series
          • BS2 Board of Education Tutorial SeriesBS2 Board of Education
          • Propeller C-Language BasicsPropeller C Basics
          • FLiP Try-It Kit C Tutorial SeriesFLiP Try-It Kit + C
          • FLiP Try-It Kit BlocklyProp TutorialsFLiP Try-It Kit + BlocklyProp
          • Badge WX Tutorial SeriesBadge WX
          • Propeller BlocklyProp Basics and ProjectsPropeller BlocklyProp Basics
          • View All Tutorial Series »
        • Browse Tutorials
        • Browse Tutorials

          Individual tutorials sorted by robot or kit, and language.
        • By Robot or Kit
          • ActivityBot
          • SumoBot WX
          • Boe-Bot
          • Shield-Bot
          • cyber:bot
          • Badge WX
          • ELEV-8
          • ARLO
        • By Language
        • By Language

          • Propeller C
          • Arduino
          • BlocklyProp
          • PBASIC
          • Python
          • MakeCode
          • View All Tutorials »
  • Educators
  • Reference
  • Downloads
  • Home
  • All Courses
  • Robotics with the Board of Education Shield for Arduino

Robotics with the Board of Education Shield for Arduino

Chapter 3 Solutions

Question Solutions

  1. Symptoms include erratic behavior such as going in unexpected directions or doing a confused dance.
  2. It’s when the Arduino restarts executing a sketch from the beginning.  Resets occur when you press/release the reset button, disconnect/reconnect power, or when the Arduino receives insufficient power due to brownout.
  3. If you add statements that make the piezospeaker play a tone at the beginning of all your sketches, it’ll play a tone if a brownout occurs.  That way, you can know whether to replace the batteries or check for an error in your navigation code.
  4. The tone function.
  5. A hertz is a measurement of the number of times per second a signal repeats itself.  It is abbreviated Hz. 

Exercise Solutions

  1. tone(4, 2000, 1500);     //example, your tone may be different.
  2. tone(4, 4000, 75);       //example, your tone may be different. 

Project Solutions

  1. Add E2 solution to the end of the for loop.
/*
 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.

  for(int pulseWidth = 1375; pulseWidth <= 1625; pulseWidth += 25)
  {
    Serial.print("pulseWidth = ");           // Display pulseWidth value
    Serial.println(pulseWidth);
    Serial.println("Press a key and click"); // User prompt
    Serial.println("Send to start servo...");

    while(Serial.available() == 0);          // Wait for character
    Serial.read();                           // Clear character

    Serial.println("Running...");
    servoLeft.writeMicroseconds(pulseWidth);   // Pin 13 servo speed = pulse
    delay(6000);                               // ..for 6 seconds
    servoLeft.writeMicroseconds(1500);         // Pin 13 servo speed = stop
    tone(4, 4000, 75);                         // Test complete
  }
}
  1. Add Servo servoRight, and servoRight.attach(12).  For same speed in opposite direction use:
servoRight.writeMicroseconds(1500 + (1500 – pulseWidth))

Remember to add a servoRight.writeMicroseconds(1500) after the 6-second run time.

/*
 Robotics with the BOE Shield – Chapter 3, Project 2
*/

#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
  servoRight.attach(12);                     // Attach right signal to P12
}  
 
void loop()                                  // Main loop auto-repeats
{

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

  for(int pulseWidth = 1375; pulseWidth <= 1625; pulseWidth += 25)
  {
    Serial.print("pulseWidth = ");           // Display pulseWidth value
    Serial.println(pulseWidth);
    Serial.println("Press a key and click"); // User prompt
    Serial.println("Send to start servo...");

    while(Serial.available() == 0);          // Wait for character
    Serial.read();                           // Clear character

    Serial.println("Running...");
    servoLeft.writeMicroseconds(pulseWidth);   // Pin 13 servo speed = pulse
    // Pin 12 servo opposite direction of pin 13 servo.
    servoRight.writeMicroseconds(1500 + (1500 - pulseWidth));   
    delay(6000);                               // ..for 6 seconds
    servoLeft.writeMicroseconds(1500);         // Pin 13 servo speed = stop
    servoRight.writeMicroseconds(1500);        // Pin 12 servo speed = stop
    tone(4, 4000, 75);                         // Test complete
  }
}

 


Printer-friendly version
Chapter 3 Challenges
Prev
Chapter 4. BOE Shield-Bot Navigation
Next

DISCUSSION FORUMS | PARALLAX INC. STORE

About | Terms of Use | Feedback: learn@parallax.com | Copyright©Parallax Inc. 2024

© 2025 Parallax Learn • Built with GeneratePress