180 Servo¶
Description |
More commonly called a Positional Servo. This servo can rotate clockwise or counterclockwise 180 degrees. It can be used to move project components to a specific location. It will attempt to hold its position when receiving a signal. |
Usage |
Control the position of the servo arm with the output pulse rate. Servo operates on a 20 ms cycle. Full Clockwise position - set duty cycle 0.5 ms Center position - set duty cycle 1.5 ms Full Counterclockwise position - set duty cycle 2.5 ms |
Voltage Range |
3 - 5.5V |
Interface Type |
Analog Output |
Example Usage |
from microbit import *
pin0.set_analog_period(20) # 20 ms cycle
# 45 deg clockwise
pin0.write_analog(1023 * 1.0 / 20)
sleep(1000) # wait 1 second
# 45 deg counterclockwise
pin0.write_analog(1023 * 2.0 / 20)
sleep(1000) # wait 1 second
# centered
pin0.write_analog(1023 * 1.5 / 20)
sleep(1000) # wait 1 second
|