We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 113872a commit c114565Copy full SHA for c114565
examples/ledangle.py
@@ -1,17 +1,20 @@
1
+import pyb
2
+
3
def led_angle(seconds_to_run_for):
4
# make LED objects
5
l1 = pyb.Led(1)
6
l2 = pyb.Led(2)
7
+ accel = pyb.Accel()
8
9
for i in range(20 * seconds_to_run_for):
10
# get x-axis
- accel = pyb.accel()[0]
11
+ x = accel.x()
12
13
# turn on LEDs depending on angle
- if accel < -10:
14
+ if x < -10:
15
l1.on()
16
l2.off()
- elif accel > 10:
17
+ elif x > 10:
18
l1.off()
19
l2.on()
20
else:
0 commit comments