Chapter 2 Challenges
Questions
- How do you connect two leads together using a breadboard?
- What function sets a digital pin’s direction?
- What function sets pin 13 to 5 V? What function sets it to 0 V?
- How can a sketch control the duration of a 5 V signal?
- What are the pulse durations that tell a continuous rotation servo to turn
- full speed clockwise,
- full speed counterclockwise,
- stay still.
- Which call would make a servo turn faster?
- servoLeft.writeMicroseconds(1440) or
- servoLeft.writeMicroseconds(1420). Why?
- How can a sketch control the duration of a certain servo signal?
Exercises
- Write a loop function that makes an LED blink 5 times per second, with an on time that’s 1/3rd of its off time. (Disconnect the servos for this exercise!)
- 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.
- 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
- 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.
- 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. Then, 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.