Datasheet
Chapter 2 • Shield, Lights, Servo Motors
72 • Robotics with the BOE Shield-Bot
Chapter 2 Challenges
Questions
1. How do you connect two leads together using a breadboard?
2. What function sets a digital pin’s direction?
3. What function sets pin 13 to 5 V? What function sets it to 0 V?
4. How can a sketch control the duration of a 5 V signal?
5. What are the pulse durations that tell a continuous rotation servo to turn
a. full speed clockwise,
b. full speed counterclockwise,
c. stay still.
6. Which call would make a servo turn faster?
a.
servoLeft.writeMicroseconds(1440) or
b.
servoLeft.writeMicroseconds(1420). Why?
7. How can a sketch control the duration of a certain servo signal?
Exercises
1. Write a loop function that makes an LED blink 5 times per second, with an on
time that’s 1/3
rd
of its off time. (Move power switch to position 1 to turn off the
servos for this exercise!)
2. Write a
setup function that makes the pin 13 servo turn full speed clockwise for
1.2 seconds, while the pin 12 servo stays still. After that, set both servos to stop.
3. Write a
setup function that makes one servo turn the same direction for 3
seconds. The other servo should turn the opposite direction for the first 1.5
seconds and the same direction for the second 1.5 seconds. Then, make both
servos stop.
Projects
1. Look up the servo library’s detach function and use it in place of servoLeft
and
servoRight.writeMicroseconds(1500) to stop servos after they turn for
3 seconds.
2. Write a program that makes the pin 13 servo turn counterclockwise while the pin
12 servo turns clockwise. After 3 seconds, make both servos turn
counterclockwise for 0.6 seconds. Next, make both turn clockwise for 0.6
seconds. Then, make the pin 13 servo turn clockwise and the pin 12 servo turn
counterclockwise for 3 seconds.