AutoSunglasses updated for current libs

changed from using simpleio.Servo to pulseio & adafruit_motor
This commit is contained in:
Collin Cunningham 2020-01-03 05:07:52 -05:00
parent d26c82ad99
commit 56d948c4ae

View file

@ -14,13 +14,15 @@ All text above must be included in any redistribution.
import time import time
import board import board
import simpleio import pulseio
from adafruit_circuitplayground.express import cpx from adafruit_circuitplayground.express import cpx
from adafruit_motor import servo
servo = simpleio.Servo(board.A1) pwm = pulseio.PWMOut(board.A1, duty_cycle=2 ** 15, frequency=50)
my_servo = servo.Servo(pwm)
cpx.pixels.fill((0, 0, 0)) cpx.pixels.fill((0, 0, 0))
servo.angle = 90 my_servo.angle = 90
while True: while True:
light_level = cpx.light light_level = cpx.light
@ -30,8 +32,8 @@ while True:
else: else:
cpx.pixels.fill((0, 0, 0)) cpx.pixels.fill((0, 0, 0))
if light_level < 200: if light_level < 200:
servo.angle = 90 my_servo.angle = 90
else: else:
servo.angle = 0 my_servo.angle = 0
time.sleep(0.25) time.sleep(0.25)