Skip to content

Commit c114565

Browse files
updated to use new pyb.Accel() object
1 parent 113872a commit c114565

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

examples/ledangle.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,20 @@
1+
import pyb
2+
13
def led_angle(seconds_to_run_for):
24
# make LED objects
35
l1 = pyb.Led(1)
46
l2 = pyb.Led(2)
7+
accel = pyb.Accel()
58

69
for i in range(20 * seconds_to_run_for):
710
# get x-axis
8-
accel = pyb.accel()[0]
11+
x = accel.x()
912

1013
# turn on LEDs depending on angle
11-
if accel < -10:
14+
if x < -10:
1215
l1.on()
1316
l2.off()
14-
elif accel > 10:
17+
elif x > 10:
1518
l1.off()
1619
l2.on()
1720
else:

0 commit comments

Comments
 (0)