tHIGH = value x 20 ms / 1024 = 77 x 20 ms / 1024 ≈ 1.504 ms ( close to 1.5 ms)
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")