forked from dhylands/upy-examples
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathelapsed.py
37 lines (33 loc) · 761 Bytes
/
elapsed.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import pyb
led = pyb.LED(3) # yellow
def blink_millis():
start = pyb.millis()
led.on()
while pyb.elapsed_millis(start) < 100:
pass
led.off()
while pyb.elapsed_millis(start) < 200:
pass
led.on()
while pyb.elapsed_millis(start) < 300:
pass
led.off()
while pyb.elapsed_millis(start) < 1000:
pass
def blink_micros():
start = pyb.micros()
led.on()
while pyb.elapsed_micros(start) < 100000:
pass
led.off()
while pyb.elapsed_micros(start) < 200000:
pass
led.on()
while pyb.elapsed_micros(start) < 300000:
pass
led.off()
while pyb.elapsed_micros(start) < 1000000:
pass
for i in range(5):
blink_millis()
blink_micros()