SunFounder Thales Kit for Raspberry Pi Pico, Release 1.0
Wiring
1. In general, this circuit is a combination of the circuits in the previous two lessons.
2. Confirm again that the breadboard power bus is not connected wrongly or short-circuited!
Code
When the program starts, the LED will turn off within 5 to 10 seconds. You need to press the button as fast as possible,
and the program will tell you what your reaction time is.
import
machine
import
utime
import
urandom
led
=
machine
.
Pin(
15
, machine
.
Pin
.
OUT)
button
=
machine
.
Pin(
14
, machine
.
Pin
.
IN)
def
button_press
(pin):
button
.
irq(handler
=
None
)
rection_time
=
utime
.
ticks_diff(utime
.
ticks_ms(), timer_light_off)
(
"Your reaction time was "
+
str
(rection_time)
+
" milliseconds!"
)
led
.
value(
1
)
utime
.
sleep(urandom
.
uniform(
5
,
10
))
led
.
value(
0
)
timer_light_off
=
utime
.
ticks_ms()
button
.
irq(trigger
=
machine
.
Pin
.
IRQ_RISING, handler
=
button_press)
60
Chapter 3. For MicroPython User
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 ...