User Manual
Pretty simple!
Note that we assume that 0 degrees is 0.5ms and 180 degrees is a pulse width of 2.5ms. That's a bit wider than
the
official
1-2ms pulse widths. If you have a servo that has a different range you can initialize the servo object with a
different min_pulse and max_pulse . For example:
servo = adafruit_motor.servo.Servo(pwm, min_pulse = 0.5, max_pulse = 2.5)
For more detailed information on using servos with CircuitPython, check out the CircuitPython section of the servo
guide (https://adafru.it/Bei)!
# Continuous Servo Test Program for CircuitPython
import time
import board
import pulseio
from adafruit_motor import servo
# create a PWMOut object on Pin A2.
pwm = pulseio.PWMOut(board.A2, frequency=50)
# Create a servo object, my_servo.
my_servo = servo.ContinuousServo(pwm)
while True:
print("forward")
my_servo.throttle = 1.0
time.sleep(2.0)
print("stop")
my_servo.throttle = 0.0
time.sleep(2.0)
print("reverse")
my_servo.throttle = -1.0
time.sleep(2.0)
print("stop")
my_servo.throttle = 0.0
time.sleep(4.0)
© Adafruit Industries https://learn.adafruit.com/adafruit-metro-m4-express-airlift-wifi Page 127 of 187