Parallel-In/Serial-Out: Interfacing the 74HC165D Shift Register with Microcontrollers
In embedded systems design, a common challenge is the scarcity of digital input pins on a microcontroller (MCU). When the number of switches, sensors, or digital signals to be monitored exceeds the available GPIOs, expanding the digital input capacity becomes essential. This is where parallel-in/serial-out (PISO) shift registers like the 74HC165D provide an elegant and efficient solution.
The 74HC165D is an 8-bit PISO shift register that allows a microcontroller to read the state of up to eight digital signals using only a few pins. Its core function is to read a parallel byte of data from its eight input pins and then output that data bit-by-bit through a single serial line, all under the control of the MCU.
Key Pin Functions of the 74HC165D
Understanding its pinout is crucial for successful interfacing:
Parallel Inputs (A-H): These eight pins (P0 to P7) are connected to the digital signals you want to read (e.g., buttons, switches).
Serial Output (QH): This pin outputs the shifted data, one bit at a time, to the MCU's digital input pin (e.g., MISO).
Complementary Serial Output (QH'): The inverted output of QH; less commonly used.
Shift/Load (SH/LD): This is the master control pin. When pulled LOW, the register loads the current state of all parallel inputs into its internal storage latches. When pulled HIGH, shifting is enabled.
Clock (CLK): On each rising edge of this clock signal from the MCU, the internal data bits shift by one position, and the next bit appears on the QH output.
Clock Inhibit (CLK INH): Holding this pin LOW allows the clock to operate. It is often tied to GND for simplicity or controlled for advanced daisy-chaining.
Serial Input (SER): Used for daisy-chaining multiple 74HC165D chips. It connects to the QH output of the previous register in the chain, allowing for input expansion to 16, 24, or more bits.
Interfacing with a Microcontroller
A typical connection between an MCU (like an Arduino or PIC) and a single 74HC165D requires only three to four GPIO pins:
1. Data Pin (MCU Input): Connected to QH of the 74HC165D.

2. Clock Pin (MCU Output): Connected to CLK of the 74HC165D.
3. Load Pin (MCU Output): Connected to SH/LD of the 74HC165D.
4. (Optional) Clock Inhibit Pin: Often tied to GND.
The Data Reading Sequence
The process for the MCU to read the parallel data is a precise sequence:
1. Load Parallel Data: The MCU pulls the SH/LD pin LOW. This instantly latches the current state of the A-H inputs into the register.
2. Enable Shifting: The MCU pulls the SH/LD pin HIGH to prepare for serial shifting.
3. Shift Out Data: The MCU pulses the CLK pin eight times. On each rising edge of the clock:
The value of the first bit (e.g., input H) appears on QH.
All subsequent bits shift one position toward the output.
The MCU reads the value on the QH line on each clock pulse (often on the rising or falling edge) and stores it.
4. Reconstruct the Byte: After eight clock pulses, the MCU has received all eight bits in series. It now reassembles them in its memory to reconstruct the original parallel byte of data.
Daisy-Chaining for More Inputs
For projects requiring more than eight inputs, multiple 74HC165D chips can be connected in series. The QH output of the first register is connected to the SER input of the second. The MCU's CLK and SH/LD lines are connected to all chips in parallel. The reading process remains the same, but the MCU must send 8 x N clock pulses (for N chips) to shift the entire data stream from all registers into the MCU. The first bit received represents the state of the last input pin of the last chip in the chain.
The 74HC165D is an indispensable component for efficient digital input expansion. Its ability to convert parallel data into a serial stream dramatically reduces the pin count required on a host microcontroller, simplifying board layout and reducing system cost. Mastering its interface protocol is a fundamental skill for embedded systems developers working with numerous digital inputs.
Keywords: Shift Register, Parallel-In/Serial-Out, Digital Input Expansion, Microcontroller Interfacing, Daisy-Chaining
