74HC165 Parallel-In Shift Register Input Expander

Read 8 buttons, switches, or sensor pins with just three Arduino pins by clocking them through a 74HC165 shift register.

Difficulty: Breadboard. Estimated build time: about 40 minutes. Estimated parts cost: about US$2.80. 5-line bill of materials. Compare supplier offers when available. An 8-input expander built around the 74HC165, the parallel-in / serial-out cousin of the 74HC595.

Wire the eight parallel inputs

DIP-16 with the notch up. Pin 1 = SH/LD, pin 2 = CLK, pin 3–6 = D4–D7, pin 7 = Q7̄, pin 8 = GND, pin 9 = Q7, pin 10 = SER, pin 11 = D0, pins 12–15 = D1–D4 (wait — see datasheet for exact ordering). For each parallel input D0–D7, wire one tactile switch from the pin to GND, and add a 10 kΩ pull-up from the pin to VCC. Idle state is HIGH; pressed is LOW.

Hook the three control lines to Arduino

SH/LD (pin 1) → Arduino D9. CLK (pin 2) → D10. Q7 (pin 9) → D11. VCC (pin 16) → 5 V. GND (pin 8) → GND. Tie SER (pin 10) to GND if you're not chaining, or to the next chip's Q7 if you are. CLK INH (pin 15) → GND so the clock is always enabled.

Write a sketch that reads all 8 inputs

In setup() configure D9, D10 as OUTPUTS and D11 as INPUT. In loop(), pulse D9 LOW for 5 µs and HIGH again — that latches the parallel inputs. Then call shiftIn(D11, D10, MSBFIRST) which clocks 8 bits out on D11 and returns a byte. Print Serial.println(value, BIN) and you'll see '11111111' with no buttons pressed and a 0 in each bit position when its switch is closed.