Questions
- Answer: Servos on larger machines are most likely bigger in size, more powerful, and more durable because they are used to drive heavier machines. This would require sturdier and more powerful equipment.
- Answer: The servo is connected to supply voltage, ground, and the control signal.
- Answer: -10 degrees and 190 degrees
- Answer: There is a built-in motion limiter.
Exercises
- Answer: 77
- Answer: 128
- Answer: pin16.write_analog()
- Answer: It sets up the servo signal so the micro:bit is ready to set P16 high and low for portions of the 20 ms period.
- Solution:
tHIGH = value x 20 ms / 1024 = 77 x 20 ms / 1024 ≈ 1.504 ms ( close to 1.5 ms)
Projects
1. Solution:
# servo_bounce_between_1 from microbit import * pin16.set_analog_period(20) while True: pin16.write_analog(26) # 0 degrees sleep(4000) pin16.write_analog(34) # 15 degrees sleep(4000)
2. Solution:
from microbit import * pin16.set_analog_period(20) print("Enter values in 51 to 102 range...") while True: text = input("Enter value >") y = int(text) if y < 103 and y > 50: pin16.write_analog(y) x = (y - 25.6) / 0.5699 print("servo degrees:", x)
3. Solution:
# terminal_controlled_servo_error from microbit import * pin16.set_analog_period(20) print("Enter values in 26 to 128 range...") while True: text = input("Enter value >") y = int(text) if y < 129 and y > 25: pin16.write_analog(y) x = (y - 25.6) / 0.5699 print("servo degrees:", x) else: print("Error, out of range")