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
    1. full speed clockwise,
    2. full speed counterclockwise,
    3. stay still.
  6. Which call would make a servo turn faster?
    1. servoLeft.writeMicroseconds(1440) or
    2. 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/3rd of its off time. (Disconnect 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.  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.