Datasheet
Shield, Lights, Servo Motors • Chapter 2
Robotics with the BOE Shield-Bot • 65
Your Turn – Center the Servo Connected to Pin 12
Repeat the process for the pin 12 servo using the sketch RightServoStayStill.
/*
Robotics with the BOE Shield – RightServoStayStill
Transmit the center or stay still signal on pin 12 for center adjustment.
*/
#include <Servo.h> // Include servo library
Servo servoRight; // Declare right servo
void setup() // Built-in initialization block
{
servoRight.attach(12); // Attach right signal to pin 12
servoRight.writeMicroseconds(1500); // 1.5 ms stay still signal
}
void loop() // Main loop auto-repeats
{ // Empty, nothing needs repeating
}
Activity 6: Testing the Servos
There’s one last thing to do before assembling your BOE Shield-Bot, and that’s testing the
servos. In this activity, you will run sketches that make the servos turn at different speeds
and directions. This is an example of subsystem testing—a good habit to develop.
Subsystem testing is the practice of testing the individual components before they go into the
larger device. It’s a valuable strategy that can help you win robotics contests.
Engineers use this essential skill to develop everything from toys, cars, and video games to space
shuttles and Mars roving robots. Especially in more complex devices, it can become nearly
impossible to figure out a problem if the individual components haven’t been tested beforehand.
In aerospace projects, for example, disassembling a prototype to fix a problem can cost hundreds
of thousands, or even millions, of dollars. In those kinds of projects, subsystem testing is rigorous
and thorough.