Interfacing the NXP 74HC165PW 8-Bit Parallel-In/Serial-Out Shift Register
In the realm of digital electronics and microcontroller projects, efficiently reading a large number of digital inputs is a common challenge. The NXP 74HC165PW is a versatile and widely-used integrated circuit that provides an elegant solution. This 8-bit parallel-in/serial-out (PISO) shift register allows a microcontroller to read eight separate digital signals using only a handful of its GPIO pins, making it an indispensable component for input expansion.
The primary function of the 74HC165 is to read the state of up to eight parallel digital input pins and transmit this data serially to a microcontroller, such as an Arduino, ESP32, or PIC. This process is controlled through a simple synchronous serial interface. The key to its operation lies in its control pins:
SH/LD (Shift/Load): This is the master control pin. When pulled LOW, the register loads the current state of its eight parallel inputs (A through H) into its internal storage latches. When pulled HIGH, the device is in shift mode.
CLK (Clock Pin): This input receives a clock pulse from the microcontroller. On each low-to-high transition (rising edge), the internal state of the shift register is shifted by one bit.

SER (Serial Input): This pin allows multiple 74HC165s to be daisy-chained together to form 16, 24, or more input registers. The serial output (Q7) of one register is connected to the SER input of the next.
Q7 (Serial Output): This pin delivers the serial data stream. The value of the highest bit (H) is output first on each clock pulse.
The standard procedure for reading data from a single 74HC165 involves a few critical steps. First, the microcontroller pulls the SH/LD pin LOW to load the parallel data. It then returns the SH/LD pin to HIGH to initiate shift mode. Finally, the microcontroller generates eight clock pulses. On each pulse, the value on the Q7 pin is read, providing the state of each input bit, one after the other, from the most significant bit (MSB) to the least significant bit (LSB).
A significant advantage of the 74HC165 is its ability to be easily daisy-chained. The serial output (Q7) of the first IC is connected to the serial input (SER) of the next. The SH/LD and CLK lines of all ICs are connected in parallel. The microcontroller then simply generates 8 x N clock pulses (where N is the number of ICs) to read the state of all inputs in a continuous stream. This creates a highly scalable system for adding dozens of inputs with minimal wiring and GPIO consumption.
ICGOOODFIND: The NXP 74HC165PW is a fundamental component for efficient input expansion in microcontroller-based systems. Its simple 3-wire serial interface, daisy-chain capability, and high-speed operation make it an ideal and cost-effective choice for reading a multitude of buttons, switches, and digital sensors.
Keywords: Shift Register, Input Expansion, Serial Interface, Daisy-chain, Microcontroller.
