The answersDownload the PDF
Worksheet

7.1 Servos

Hands and feet · Robot club · about 15 min

BugBotLab
NameClassDate

What this lesson is about

Angles, speed, what a servo can and cannot do.

Questions 7 marks in all

  1. [1 mark]What does the number 90 mean in servo(0, 90)?

    1. AThe angle for servo 0 to go to and hold
    2. BHow fast servo 0 should spin
    3. CHow many seconds servo 0 should run for
    4. DHow many degrees to turn from where it is now
  2. [1 mark]Which servo works which attachment on BugBot?

    1. AServo 0 the gripper, servo 1 the kicker
    2. BServo 0 the kicker, servo 1 the gripper
    3. CServo 1 the gripper, servo 2 the kicker
    4. DBoth servos work the gripper together
  3. [1 mark]What does this program print?

    for angle in range(0, 181, 45):
        print("servo 0 at", angle)
  4. [1 mark]A hobby servo turns about 60 degrees in a tenth of a second. About how many seconds does it take to swing from 0 to 180? Give your answer to one decimal place.

  5. [1 mark]A program runs servo(0, 180) and on the very next line servo(0, 0), with no wait between. What does servo 0 do?

    1. AIt barely moves, because it is sent back to 0 before it gets anywhere near 180
    2. BIt goes all the way to 180, then back to 0
    3. CPython stops with an error
    4. DIt waits at 180 until you call wait
  6. [1 mark]Which of these can a normal (not continuous-rotation) servo NOT do?

    Tick every answer that is true.

    1. ASpin round and round
    2. BTell you what it touched
    3. CPush harder than its small gearbox allows
    4. DHold an angle once it gets there
    5. EGo to 45 degrees
  7. [1 mark]What does this program print?

    for angle in range(180, -1, -60):
        print(angle)

The task: servo sweep

Move servo 0 to 0, 45, 90, 135 and 180 in turn, printing servo 0 at <angle> each time. Do not drive.

# the two lines every program starts with: the commands, then the robot
from bugbot import *
connect()

# servo 0 to 90 degrees
servo(0, 90)
print("servo 0 at", 90)

Plan your program here, then type it in and press Run.

QR code
Do it on the robot
www.bugbotlab.com/learn/7-1-servos/
The simulator checks it and tells you when it passes. Nothing to install, no account.

Challenges

  1. Sweep servo 1 the same way and watch the kicker. It is the continuous-rotation kind, so the angle sets whether it turns, not where it points, and it keeps turning until it is sent 90. End with servo(1, 90).
  2. Wave: swing servo 0 between 60 and 120 five times.
  3. Write slowly(index, angle) that moves a servo to an angle in steps of 5 degrees with a short wait between each.