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.
Parts from the database
- SN74HC165N ร 1Eight parallel inputs to serial
- Raspberry-Pi-Pico ร 1Reads serial state
Other supplies
- breadboardCommon build supply
- eight switchesCommon build supply
- eight 10 kฮฉ pull-upsCommon build supply
- 100 nF bypassCommon build supply
- jumper wiresCommon build supply
- MicroPython installedCommon build supply
Amazon links may be affiliate links. As an Amazon Associate, Electronics Hobby Hub earns from qualifying purchases.
Connections
- Power HC165 pin 16 from Pico 3V3 and pin 8 to ground; bypass. Tie CLK INH pin 15 low and SER pin 10 low.
- 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.
- 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
- Run the code below and press one switch at a time.
- It pulses /PL low, then reads Q7 while clocking eight bits.
- Record which printed bit changes for each physical switch.
- 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)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.