from adafruit_circuitplayground import cp
import time

cp.pixels.brightness = 0.2
cp.pixels.fill((0, 0, 0))  # Turn off the NeoPixels if they're on!

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:
    # lights 
    cp.pixels[0:5] = [(255, 0, 0)] * 5
    cp.pixels[5:10] = [(0, 0, 255)] * 5
    time.sleep(1)
    cp.pixels[0:5] = [(0, 0, 255)] * 5
    cp.pixels[5:10] = [(255, 0, 0)] * 5
    time.sleep(1)

    # Servo
    my_servo.throttle = 1.0
    time.sleep(5)
    my_servo.throttle = 0.0
    time.sleep(1)
    my_servo.throttle = -1.0
    time.sleep(5)
    my_servo.throttle = 0.0
    time.sleep(1)
    
    # Sound 
    cp.play_tone(262, 1)
    cp.play_tone(272, 1)
    cp.play_tone(282, 1)
    cp.play_tone(230, 1)
    cp.play_tone(200, 1)
    cp.play_tone(300, 1)