# crickit/servo_sweep.py

# Demonstrate oscillating movement of a hobby servo.  The Crickit supports up to
# four hobby servos; please note that the control line should be oriented toward
# the outside edge of the board, adjaced to the number marking.  On our micro
# servos, this wire is orange.

# Related documentation:
# http://docs.circuitpython.org/projects/crickit/en/latest/
# http://docs.circuitpython.org/projects/seesaw/en/latest/
# https://learn.adafruit.com/adafruit-crickit-creative-robotic-interactive-construction-kit

# ----------------------------------------------------------------
# Import the standard Python time functions.
import time

# Import the Crickit interface library.
from adafruit_crickit import crickit

# ----------------------------------------------------------------
# Begin the main processing loop.
while True:
    print("Starting cycle.")
    for angle in range(0, 180, 5):
        crickit.servo_1.angle = angle
        time.sleep(0.02)

    print("Reversing cycle.")
    for angle in range(180, 0, -5):
        crickit.servo_1.angle = angle
        time.sleep(0.02)

    print("Pausing.")
    time.sleep(0.5)
    
