25 lines
563 B
Python
25 lines
563 B
Python
# 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)
|