Adafruit_Learning_System_Gu.../CircuitPython_Essentials/CircuitPython_Continuous_Servo.py
2021-01-27 18:10:08 -05:00

25 lines
580 B
Python

"""CircuitPython Essentials Servo continuous rotation servo example"""
import time
import board
import pwmio
from adafruit_motor import servo
# create a PWMOut object on Pin A2.
pwm = pwmio.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)