code.py
 1  # SPDX-FileCopyrightText: 2021 Brent Rubell for Adafruit Industries
 2  #
 3  # SPDX-License-Identifier: MIT
 4  
 5  """
 6  'servo.py'.
 7  
 8  =================================================
 9  move a hobby servo (towerpro sg92r) w/ 3-wire interface
10  requires:
11  - Adafruit_CircuitPython_Motor
12  """
13  import time
14  import board
15  import pwmio
16  from adafruit_motor import servo
17  
18  SERVO = servo.Servo(pwmio.PWMOut(board.D9))
19  
20  while True:
21      SERVO.angle = 0
22      time.sleep(2)
23      SERVO.angle = 90
24      time.sleep(2)