Parallel-In/Serial-Out Shift Register: Interfacing with the NXP 74HC165
In digital electronics, efficiently reading multiple digital inputs with a limited number of microcontroller (MCU) GPIO pins is a common challenge. A parallel-in/serial-out (PISO) shift register provides an elegant and cost-effective solution to this problem. The NXP 74HC165 is one of the most popular and widely used integrated circuits in this category, enabling designers to expand the digital input capacity of a system using a minimal number of control lines.
The core function of a PISO shift register is to read in a parallel byte (or word) of data and then output it serially, bit by bit, through a single data line. This process allows a host controller, such as an Arduino, Raspberry Pi, or other MCU, to read the state of up to eight digital sensors or switches using just three GPIO pins: one for data, one for the clock, and one for latch control.
The 74HC165 is an 8-bit PISO shift register that operates on a straightforward principle. Its operation is governed by two primary control signals: the shift/load (SH/LD) signal and the clock (CLK) signal. When the SH/LD pin is pulled LOW, the register simultaneously latches the state of its eight parallel input pins (A through H) into its internal storage. When the SH/LD pin is HIGH, the device is in shift mode. With each subsequent rising edge on the CLK pin, the stored data is shifted one bit towards the serial output (QH). The complementary serial output (QH') is also provided for daisy-chaining multiple devices, further expanding input capabilities without additional control pins.
Interfacing the 74HC165 with a microcontroller is a simple process. The typical connection involves:
Connecting the eight parallel input pins to the sensors or switches to be monitored.
Wiring the SH/LD pin to a GPIO pin on the MCU.
Connecting the CLK pin to another GPIO pin.

Reading the serial data stream from the QH pin via a third GPIO pin.
The software routine on the MCU follows a clear sequence:
1. Latch the Data: The MCU pulls the SH/LD pin LOW to sample and latch the current state of all parallel inputs.
2. Shift the Data: The MCU returns the SH/LD pin to HIGH to initiate shift mode. It then pulses the CLK pin eight times.
3. Read the Bits: On each clock pulse, the MCU reads the value on the serial data line (QH), typically reading the most significant bit (MSB) first. These bits are combined to reconstruct the original parallel byte.
A key advantage of the 74HC165 is its ability to be daisy-chained for input expansion. The serial output (QH') of one register is connected to the serial data input (SER) of the next. By pulsing the clock more times (e.g., 16 times for two chips), the MCU can read the data from all cascaded registers in one continuous stream.
In conclusion, the 74HC165 is an indispensable component for optimizing resource usage in embedded designs. It effectively reduces the GPIO pin count required for reading multiple digital inputs, leading to cleaner designs and freeing up critical MCU pins for other tasks. Its simplicity, reliability, and daisy-chaining capability make it a fundamental building block in data acquisition systems, industrial control panels, and large-scale button matrices.
ICGOODFIND: The NXP 74HC165 is a quintessential PISO shift register, offering a perfect blend of simplicity and powerful functionality for digital input expansion, making it an excellent IC choice for hobbyists and professional engineers alike.
Keywords: Shift Register, Parallel-In/Serial-Out, GPIO Expansion, Daisy-Chaining, Digital Input.
