AutoSunglasses updated for current libs
changed from using simpleio.Servo to pulseio & adafruit_motor
This commit is contained in:
parent
d26c82ad99
commit
56d948c4ae
1 changed files with 7 additions and 5 deletions
|
|
@ -14,13 +14,15 @@ All text above must be included in any redistribution.
|
|||
|
||||
import time
|
||||
import board
|
||||
import simpleio
|
||||
import pulseio
|
||||
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))
|
||||
servo.angle = 90
|
||||
my_servo.angle = 90
|
||||
|
||||
while True:
|
||||
light_level = cpx.light
|
||||
|
|
@ -30,8 +32,8 @@ while True:
|
|||
else:
|
||||
cpx.pixels.fill((0, 0, 0))
|
||||
if light_level < 200:
|
||||
servo.angle = 90
|
||||
my_servo.angle = 90
|
||||
else:
|
||||
servo.angle = 0
|
||||
my_servo.angle = 0
|
||||
|
||||
time.sleep(0.25)
|
||||
|
|
|
|||
Loading…
Reference in a new issue