
SunFounder Thales Kit for Raspberry Pi Pico, Release 1.0
Insert the following statement into the second line of the program:
import
utime
Like machine, the
utime
library is introduced here, which handles all time-related things, including the delay we
need to use. Let’s insert a delay sentence between
led_onboard.value(1)
and
led_onboard.value(0)
,
let them be separated by 2 seconds:
utime
.
sleep(
2
)
Now, the code should look like this. Run it, we will be able to see that the onboard LED turns on first and then turns
off:
import
machine
import
utime
led_onboard
=
machine
.
Pin(
25
, machine
.
Pin
.
OUT)
led_onboard
.
value(
1
)
utime
.
sleep(
2
)
led_onboard
.
value(
0
)
Finally, we should make the LED blink. Create a loop, rewrite the program, and it will be what you saw at the
beginning of this chapter.
import
machine
import
utime
led_onboard
=
machine
.
Pin(
25
, machine
.
Pin
.
OUT)
while
True
:
led_onboard
.
value(
1
)
utime
.
sleep(
2
)
led_onboard
.
value(
0
)
utime
.
sleep(
2
)
What More?
Usually, the library will have a corresponding API (Application Programming Interface) file. This is a concise ref-
erence manual that contains all the information needed to use this library, detailed introduction to functions, classes,
return types, parameters, etc., and even comes with a tutorial.
In this article, we used MicroPython’s
machine
and
utime
libraries, we can find more ways to use them here.
•
•
The following is also an example of making the LED blink, please try to read the API file to understand it!
import
machine
import
utime
led_onboard
=
machine
.
Pin(
25
, machine
.
Pin
.
OUT)
while
True
:
led_onboard
.
toggle()
utime
.
sleep(
1
)
3.4. Projects
51
Summary of Contents for Thales Kit
Page 1: ...SunFounder Thales Kit for Raspberry Pi Pico Release 1 0 Jimmy SunFounder Jun 04 2021 ...
Page 2: ......
Page 4: ...ii ...
Page 6: ...SunFounder Thales Kit for Raspberry Pi Pico Release 1 0 2 CONTENTS ...
Page 140: ...SunFounder Thales Kit for Raspberry Pi Pico Release 1 0 136 Chapter 3 For MicroPython User ...
Page 164: ...SunFounder Thales Kit for Raspberry Pi Pico Release 1 0 160 Chapter 4 For Arduino User ...