# accelerometer_servo_points_up from microbit import * import math while True: x = accelerometer.get_x() y = accelerometer.get_y() angle = round( math.degrees( math.atan2(y, x) ) ) needle = ( angle - 90 + 15 ) // 30 display.show(Image.ALL_CLOCKS[needle]) if angle >= 0: angle = 180 - angle else: continue value = 0.5689 * angle + 25.6 pin16.write_analog(value)
It's time to verify that your micro:bit LED matrix and servo behavior resemble what’s shown in the animation.
Links
[1] https://python.microbit.org/v/2
[2] https://learn.parallax.com/sites/default/files/content/Python/servo/servo-tilt-ctrl-concept.mp4