Preview build — page text is a draft awaiting human review. Code badges come from real compiles. The flasher is real but not yet hardware-tested; the Playground is still a preview.

74HC595 shift register with Raspberry Pi Pico — 8 LEDs from 3 pins in MicroPython

Drive 8 LEDs from a 74HC595 on a Raspberry Pi Pico using hardware SPI0 (GP18/GP19) and a latch on GP17 in MicroPython: binary counter and Knight Rider.

MicroPythonVerified — micropython (mpy-cross v1.29.0), 3 Nov 2026Compile-only

Community draft — report a mistake

The 74HC595 turns three Pico pins into eight outputs — and more if you chain chips. On the Raspberry Pi Pico it fits perfectly on SPI0: SCK on GP18 clocks the bits in, TX on GP19 carries the data, and GP17 latches them to the outputs.

Run it at 3V3 with an LED and 220 Ω resistor on each output. The script counts in binary from 0 to 255, then runs a Knight Rider sweep.

Wiring

Raspberry Pi PicoOnly the pins used are shown · 3.3 V logic74HC595 8-bit shift register (DIP-16)GND3V3GP19GP18GP17VCCGNDDSSH_CPST_CPOEMRQ0 → LED 1 + 220 Ω to GNDQ1 → LED 2 + 220 Ω to GNDQ2 → LED 3 + 220 Ω to GNDQ3 → LED 4 + 220 Ω to GNDQ4 → LED 5 + 220 Ω to GNDQ5 → LED 6 + 220 Ω to GNDQ6 → LED 7 + 220 Ω to GNDQ7 → LED 8 + 220 Ω to GNDQ7S (not connected)
Also needed: 8 LEDs, 8 × 220 Ω resistors, 100 nF capacitor across VCC/GND at the chip.
Every connection
Raspberry Pi Pico74HC595 8-bit shift register (DIP-16)WireNotes
—Q0—To LED 1 + 220 Ω to GND (not drawn)
—Q1—To LED 2 + 220 Ω to GND (not drawn)
—Q2—To LED 3 + 220 Ω to GND (not drawn)
—Q3—To LED 4 + 220 Ω to GND (not drawn)
—Q4—To LED 5 + 220 Ω to GND (not drawn)
—Q5—To LED 6 + 220 Ω to GND (not drawn)
—Q6—To LED 7 + 220 Ω to GND (not drawn)
—Q7—To LED 8 + 220 Ω to GND (not drawn)
3V3VCCredChip pin 16. Run the 595 at 3.3 V, the same as the Pico, so every logic level matches.
GNDGNDblackChip pin 8.
GP19DSgreenSPI0 TX, physical pin 25 → serial data (chip pin 14).
GP18SH_CPyellowSPI0 SCK, physical pin 24 → shift clock (chip pin 11).
GP17ST_CPorangePhysical pin 22 → latch (chip pin 12).
GNDOEblackChip pin 13: outputs always enabled.
3V3MRredChip pin 10: never reset.

2–6 V part, 3.3 V board. Power it from the same voltage as your board: 3.3 V on ESP32 and Pico, 5 V on Uno. At 5 V the 74HC595 needs about 3.15 V for a HIGH, so a 3.3 V board driving a 5 V-powered chip is marginal — use a 74HCT595 at 5 V for that.

Board quirks

  • A shift register is exactly what SPI was made for, so the Pico’s hardware SPI0 clocks the byte out in microseconds: spi.write(bytes([b])), then pulse the latch.
  • At 3.3 V a 74HC595 output can supply a few mA per LED — fine with 220 Ω. For brighter LEDs or relays, follow it with a ULN2003.
  • Chain more 595s by wiring Q7S of the first to DS of the next and sharing SH_CP/ST_CP; then write 2, 3, … bytes before the latch pulse.
  • Don’t power the 595 from 5 V while driving it from the Pico: a 74HC595 at 5 V needs about 3.15 V for HIGH, which 3.3 V only just meets.

Code

main.pyMicroPython
# 74HC595 shift register driving 8 LEDs from a Raspberry Pi Pico (MicroPython, hardware SPI).
# Wiring: VCC -> 3V3 (pin 36), GND -> GND, DS -> GP19 (pin 25, SPI0 TX),
# SH_CP -> GP18 (pin 24, SPI0 SCK), ST_CP (latch) -> GP17 (pin 22), OE -> GND, MR -> 3V3.
# Q0-Q7 -> LED anode -> 220 Ohm -> GND (one resistor per LED).
from machine import Pin, SPI
import time

spi = SPI(0, baudrate=1_000_000, polarity=0, phase=0, sck=Pin(18), mosi=Pin(19), miso=Pin(16))
latch = Pin(17, Pin.OUT, value=0)


def show(byte):
    spi.write(bytes([byte]))  # 8 bits out MSB first: bit 7 ends up on Q7, bit 0 on Q0
    latch.value(1)            # rising edge copies the shifted bits to the outputs at once
    latch.value(0)


print("74HC595 on SPI0 (GP18/GP19), latch GP17")
while True:
    print("Binary counter 0-255")
    for n in range(256):
        show(n)
        time.sleep_ms(30)
    print("Knight Rider")
    for _ in range(3):
        for i in list(range(8)) + list(range(6, 0, -1)):
            show(1 << i)
            time.sleep_ms(70)
    show(0)
    time.sleep(1)

Expected serial output

REPL / Thonny shellOutput
74HC595 on SPI0 (GP18/GP19), latch GP17
Binary counter 0-255
Knight Rider

Common errors

All LEDs on or flickering randomly

MR or OE is floating. Tie MR to 3V3 and OE to GND.

Pattern is mirrored

SPI sends bit 7 first, so it lands on Q7. Reverse the LED order on the breadboard or reverse the bits in code.

↑↓ to move · Enter to open