IntermediateInterfaces & Logic

Eight-Button Serial Input Expander

Capture eight switch states in parallel with an SN74HC165, then shift them to the Pico over three GPIO wires.

Estimated time: 1โ€“2 hours ยท Skills: Parallel load, serial shifting, pull-up inputs

Parts from the database

Other supplies

Amazon links may be affiliate links. As an Amazon Associate, Electronics Hobby Hub earns from qualifying purchases.

Connections

  1. Power HC165 pin 16 from Pico 3V3 and pin 8 to ground; bypass. Tie CLK INH pin 15 low and SER pin 10 low.
  2. Inputs D0โ€“D7 are pins 11,12,13,14,3,4,5,6; each gets a 10 kฮฉ pull-up to 3.3 V and button to ground.
  3. Connect /PL pin 1 to Pico GP2, CLK pin 2 to GP3, and Q7 pin 9 to GP4. Keep all signals within 0โ€“3.3 V.

Build steps

  1. Run the code below and press one switch at a time.
  2. It pulses /PL low, then reads Q7 while clocking eight bits.
  3. Record which printed bit changes for each physical switch.
  4. Add debounce/repeated sampling before using states to control anything.

Software and firmware setup

from machine import Pin
from time import sleep_ms
load = Pin(2, Pin.OUT, value=1)
clock = Pin(3, Pin.OUT, value=0)
data = Pin(4, Pin.IN)
while True:
    load.value(0); load.value(1)
    value = 0
    for _ in range(8):
        value = (value << 1) | data.value()
        clock.value(1); clock.value(0)
    print('{:08b}'.format(value))
    sleep_ms(100)

Review the pin assignments in the sketch against the wiring table before uploading.

Test your build

The console prints an eight-bit word. A pressed switch reads as zero with pull-up wiring; bit display order follows the shift convention.

Troubleshooting

  • No change: verify /PL pulse and pin mapping.
  • Inverted bits: expected because switches pull inputs low.
  • Multiple bits change: check each D input and pull-up.

Safety and limitations

Use 3.3 V throughout; never place 5 V pull-ups on Pico GPIO.

Manufacturer and platform documentation

Community Notes for This Project

These are unverified visitor contributions, separate from the build guide and manufacturer specifications. Verify technical advice against the linked datasheets before relying on it.

Set up the comments service to load community notes.

Share a tip or question about this build

โ† Browse all projects