Hands and feet · Robot club · about 15 min
Angles, speed, what a servo can and cannot do.
[1 mark]What does the number 90 mean in servo(0, 90)?
[1 mark]Which servo works which attachment on BugBot?
[1 mark]What does this program print?
for angle in range(0, 181, 45):
print("servo 0 at", angle)servo 0 at 0 servo 0 at 45 servo 0 at 90 servo 0 at 135 servo 0 at 180
The third number in range is the step. Stopping at 181 rather than 180 is what lets 180 itself be included.
[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.
wait sits between moves.[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?
servo does not wait for the move to finish. Without a wait, the second command arrives while the first is still starting.[1 mark]Which of these can a normal (not continuous-rotation) servo NOT do?
Tick every answer that is true.
[1 mark]What does this program print?
for angle in range(180, -1, -60):
print(angle)180 120 60 0
A negative step counts down. Stopping at -1 means 0 is the last value printed.
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)The hint students can ask for: Move servo 0 to 0, 45, 90, 135 and 180 degrees in turn, printing servo 0 at <angle> each time, with a short wait between. Do not drive.
from bugbot import *
connect()
for angle in [0, 45, 90, 135, 180]:
servo(0, angle)
print('servo 0 at', angle)
wait(0.5)
Any program that meets the task's checks is marked correct in the simulator; this is one way, not the only way.