SunFounder Thales Kit for Raspberry Pi Pico, Release 1.0
2. Insert 74HC595 across the middle gap into the breadboard.
3. Connect the GP0 pin of Pico to the DS pin (pin 14) of 74HC595 with a jumper wire.
4. Connect the GP1 pin of Pico to the STcp pin (12-pin) of 74HC595.
5. Connect the GP2 pin of Pico to the SHcp pin (pin 11) of 74HC595.
6. Connect the VCC pin (16 pin) and MR pin (10 pin) on the 74HC595 to the positive power bus.
7. Connect the GND pin (8-pin) and CE pin (13-pin) on the 74HC595 to the negative power bus.
8. Insert 8 LEDs on the breadboard, and their anode leads are respectively connected to the Q0~Q1 pins (15, 1, 2,
3, 4, 5, 6, 7) of 74HC595.
9. Connect the cathode leads of the LEDs with a 220 resistor in series to the negative power bus.
Code
import
machine
import
time
sdi
=
machine
.
Pin(
0
,machine
.
Pin
.
OUT)
rclk
=
machine
.
Pin(
1
,machine
.
Pin
.
OUT)
srclk
=
machine
.
Pin(
2
,machine
.
Pin
.
OUT)
def
hc595_shift
(dat):
rclk
.
low()
time
.
sleep_ms(
5
)
for
bit
in
range
(
7
,
-
1
,
-
1
):
srclk
.
low()
time
.
sleep_ms(
5
)
value
=
1
&
(dat
>>
bit)
sdi
.
value(value)
time
.
sleep_ms(
5
)
srclk
.
high()
time
.
sleep_ms(
5
)
time
.
sleep_ms(
5
)
rclk
.
high()
time
.
sleep_ms(
5
)
num
=
0
for
i
in
range
(
16
):
if
i
<
8
:
num
=
(num
<<
1
)
+
1
elif
i
>=
8
:
num
=
(num
&
0b01111111
)
<<
1
hc595_shift(num)
(
"{:0>8b}"
.
format(num))
time
.
sleep_ms(
200
)
When the program is running,
num
will be written into the 74HC595 chip as an eight-bit binary number to control the
on and off of the 8 LEDs. We can see the current value of
num
in the shell.
3.4. Projects
97
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 ...