Skip to content

Commit 647be29

Browse files
authored
Merge pull request #983 from adafruit/automatic_sunglasses_update
AutoSunglasses updated for current libs
2 parents d26c82a + 56d948c commit 647be29

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

AutoSunglasses/code.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,15 @@
1414

1515
import time
1616
import board
17-
import simpleio
17+
import pulseio
1818
from adafruit_circuitplayground.express import cpx
19+
from adafruit_motor import servo
1920

20-
servo = simpleio.Servo(board.A1)
21+
pwm = pulseio.PWMOut(board.A1, duty_cycle=2 ** 15, frequency=50)
22+
my_servo = servo.Servo(pwm)
2123

2224
cpx.pixels.fill((0, 0, 0))
23-
servo.angle = 90
25+
my_servo.angle = 90
2426

2527
while True:
2628
light_level = cpx.light
@@ -30,8 +32,8 @@
3032
else:
3133
cpx.pixels.fill((0, 0, 0))
3234
if light_level < 200:
33-
servo.angle = 90
35+
my_servo.angle = 90
3436
else:
35-
servo.angle = 0
37+
my_servo.angle = 0
3638

3739
time.sleep(0.25)

0 commit comments

Comments
 (0)