File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -20,14 +20,25 @@ See :mod:`pyb`. ::
2020
2121 import pyb
2222
23- pyb.delay(50) # wait 50 milliseconds
24- pyb.millis() # number of milliseconds since bootup
2523 pyb.repl_uart(pyb.UART(1, 9600)) # duplicate REPL on UART(1)
2624 pyb.wfi() # pause CPU, waiting for interrupt
2725 pyb.freq() # get CPU and bus frequencies
2826 pyb.freq(60000000) # set CPU freq to 60MHz
2927 pyb.stop() # stop CPU, waiting for external interrupt
3028
29+ Delay and timing
30+ ----------------
31+
32+ Use the :mod: `time <utime> ` module::
33+
34+ import time
35+
36+ time.sleep(1) # sleep for 1 second
37+ time.sleep_ms(500) # sleep for 500 milliseconds
38+ time.sleep_us(10) # sleep for 10 microseconds
39+ start = time.ticks_ms() # get value of millisecond counter
40+ delta = time.ticks_diff(start, time.ticks_ms()) # compute time difference
41+
3142LEDs
3243----
3344
You can’t perform that action at this time.
0 commit comments