code.py
 1  # SPDX-FileCopyrightText: 2019 Anne Barela for Adafruit Industries
 2  #
 3  # SPDX-License-Identifier: MIT
 4  
 5  """CircuitPython Essentials Servo continuous rotation servo example"""
 6  import time
 7  import board
 8  import pwmio
 9  from adafruit_motor import servo
10  
11  # create a PWMOut object on Pin A2.
12  pwm = pwmio.PWMOut(board.A2, frequency=50)
13  
14  # Create a servo object, my_servo.
15  my_servo = servo.ContinuousServo(pwm)
16  
17  while True:
18      print("forward")
19      my_servo.throttle = 1.0
20      time.sleep(2.0)
21      print("stop")
22      my_servo.throttle = 0.0
23      time.sleep(2.0)
24      print("reverse")
25      my_servo.throttle = -1.0
26      time.sleep(2.0)
27      print("stop")
28      my_servo.throttle = 0.0
29      time.sleep(4.0)