Skip to content
Home > Components > Logic Components > 74HC165 Shift Register

74HC165 Shift Register

An 8-bit parallel-in, serial-out shift register used to expand digital inputs on a microcontroller.

Component Preview

74HC16574HC165

The 74HC165 is an 8-bit parallel-in/serial-out shift register. It takes up to 8 individual digital inputs (like 8 buttons or switches) and allows a microcontroller to read all 8 states using only 3 digital pins. Multiple 74HC165 chips can be daisy-chained to read an almost unlimited number of inputs.

Logic ComponentsShift RegisterInput Expansion

Overview

When you run out of input pins on an Arduino, the 74HC165 is the standard solution. By parallel-loading the inputs into the chip's internal memory and then serially shifting them out one bit at a time, you can massively expand your input capabilities.

Pin Reference

PinTypeDescription
VCCpowerPower supply (3V to 5V).
GNDpowerGround reference.
D0-D7input8 parallel digital inputs to be sampled (e.g., buttons, sensors).
PLinputParallel Load (SH/LD). Active LOW. When LOW, loads the states of D0-D7 into the shift register. When HIGH, data can be shifted.
CPinputSerial Clock (CLK). On the rising edge, data shifts one position.
CEinputClock Enable. Active LOW. Usually tied to GND permanently.
Q7digitalSerial Output (QH). Outputs the final bit. Connect to the MCU to read data.
Q7_NdigitalInverted Serial Output (QH'). Rarely used.
DSinputSerial Input (SER). Used for cascading. Connect to Q7 of a preceding chip.

Configurable Attributes

This component currently has no configurable attributes in the simulator.

Working Principle

  1. Load Phase: By pulling the Parallel Load (PL) pin LOW, the chip takes a snapshot of the digital states currently on pins D0 through D7 and stores them internally.
  2. Shift Phase: When PL is brought HIGH, the data is locked in. The first bit (D7) appears on the Q7 pin.
  3. Every time the Clock (CP) pin goes from LOW to HIGH, all stored bits shift over by one position, allowing the microcontroller to read each bit sequentially from the Q7 pin.

Wiring Diagram

Example of connecting a 74HC165 Shift Register to an Arduino Uno.

Wiring Diagram

Example Arduino Code

cpp
const int plPin = 8;  // Parallel Load pin
const int cePin = 9;  // Clock Enable pin (can also just tie to GND)
const int q7Pin = 11; // Data Out pin
const int cpPin = 12; // Clock pin

void setup() {
  Serial.begin(9600);
  pinMode(plPin, OUTPUT);
  pinMode(cePin, OUTPUT);
  pinMode(cpPin, OUTPUT);
  pinMode(q7Pin, INPUT);
  
  // Initialize pins
  digitalWrite(cpPin, LOW);
  digitalWrite(plPin, HIGH);
}

void loop() {
  // Step 1: Sample the inputs by pulsing PL low
  digitalWrite(plPin, LOW);
  delayMicroseconds(5);
  digitalWrite(plPin, HIGH);

  // Step 2: Read the 8 bits from the shift register
  byte incomingData = shiftIn(q7Pin, cpPin, MSBFIRST);

  // Print the binary representation to the Serial Monitor
  Serial.print("Data: ");
  Serial.println(incomingData, BIN);
  
  delay(500);
}

Simulation Notes

  • The simulator updates the output instantly upon clock edges and load commands.
  • If you notice bouncing or inconsistent reads, verify that your virtual buttons have proper pull-up/pull-down configurations in your circuit layout.

Released under the MIT License.