When working with Arduino, you may often need to control multiple devices like LEDs, sensors, or modules. However, as the number of connected peripherals grows, you can quickly run out of available GPIO pins. So, how can you expand your Arduino’s I/O capabilities? The solution is to use a shift register, which can effectively increase the number of input or output pins.
Shift registers come in two main types:
SIPO (Serial-In Parallel-Out) – used to expand outputs.
PISO (Parallel-In Serial-Out) – used to expand inputs.
One of the most commonly used SIPO shift register ICs is the 74HC595. It enables you to control 8 output devices using just 3 digital pins from the Arduino. Even better, you can daisy-chain multiple 74HC595 ICs to control a large number of devices using the same 3 pins.
Whether you're designing an LED matrix, a multiplexed display, or any project requiring efficient serial-to-parallel output control, the 74HC595 is an excellent choice. In this tutorial, we’ll take a closer look at how the 74HC595 works and how to interface it with an Arduino.
Let’s dive in!
What is a Shift Register and Why Use It?
The 74HC595 is an 8-bit Serial-In Parallel-Out (SIPO) shift register with a built-in D-type latch. It offers three output states: HIGH, LOW, and High-Impedance (Hi-Z). The high-impedance state allows multiple devices to share the same output lines without interference.
Let’s look at a practical example. Suppose you want to create light patterns on an 8×8 LED matrix. This matrix has 64 LEDs, and ideally, each LED requires a separate control line. Controlling all 64 LEDs directly would need 64 I/O pins, which isn’t feasible with most microcontrollers like the Arduino Uno (which only has 14 digital I/O pins).
By using two 74HC595 shift registers—one for controlling rows and one for columns—you can control all 64 LEDs using just 6 pins from your Arduino. This makes shift registers extremely valuable when working with projects that need many digital outputs.
It’s important to note that shift registers like the 74HC595 provide digital outputs only, meaning they can turn connected devices ON or OFF (logic HIGH or LOW). While they don't support analog output natively (like PWM for dimming LEDs), workarounds such as software-based PWM can be used to simulate brightness control.
Key Features of the 74HC595
- 8-bit parallel output
- Serial-to-parallel data conversion
- Cascade capability to expand outputs
- Low power consumption
- Operates with 2.0V to 6.0V supply voltage
- Compatible with 5V logic systems
How Does the 74HC595 Shift Register Work?
The 74HC595 IC contains two main components:
- Shift Register
- Storage Register (Latch)
Here’s how it works:
Data is sent one bit at a time to the Data (DS) pin. On every rising edge of the Shift Register Clock (SRCLK), the bits shift from LSB to MSB inside the shift register. After all 8 bits are loaded, a pulse is sent to the Latch Clock (RCLK) pin. This transfers the data from the shift register to the storage register, which then drives the output pins (QA to QH). This process ensures that the outputs only update after all data bits have been shifted in, avoiding flicker or glitches.
74HC595 Pinout
The 74HC595 is a widely used 8-bit shift register IC. Below is a description of its pin configuration and functionality.
Output Pins (QA to QH)
These are the eight output pins of the storage register, labeled QA to QH (also referred to as Q0 to Q7). Each pin corresponds to one bit of the stored data. The pin numbers on the IC are as follows:
QA – Pin 15
QB – Pin 1
QC– Pin 2
QD – Pin 3
QE – Pin 4
QF – Pin 5
QG – Pin 6
QH – Pin 7
Serial Data Input (SER)
This pin is used to input data serially (bit by bit) into the shift register.
Shift Register Clock (SRCLK)
Each rising edge (LOW to HIGH transition) of the clock signal shifts the bits in the shift register one position to the left, making room for a new bit at the LSB. Timing on this pin is critical for accurate data loading.
Storage Register Clock / Latch (RCLK)
This pin latches the data from the shift register into the storage register. When it transitions from LOW to HIGH, the output pins (QA to QH) are updated to reflect the new data.
Cascade Output (QH′)
Also called the serial out, this pin outputs the last bit (bit 7 or QH) of the shift register. It is used to cascade multiple 74HC595 ICs. By connecting this pin to the SER pin of another shift register and sharing the same clock signals, you can expand the number of outputs to 16, 24, or more.
Output Enable (OE)
This is an active LOW pin. Pulling it LOW enables all output pins (QA to QH); pulling it HIGH puts the outputs in a high-impedance (Hi-Z) state, effectively disconnecting them. This is useful when multiple devices share output lines. Additionally, you can use a PWM signal on this pin to control LED brightness.
Shift Register Clear (SRCLR)
This is an active LOW pin used to clear the shift register (reset all bits to 0). Note that this action does not affect the storage register. Typically, this pin is connected to VCC for normal operation.
VCC
This is the power supply pin and should be connected to +5V.
GND
This is the ground pin and should be connected to the Arduino’s GND.
Wiring a 74HC595 Shift Register to an Arduino
In this project, we’ll control 8 red LEDs using a 74HC595 shift register. The LEDs will be connected to the output pins QA to QH of the IC.
Step-by-Step Instructions:
1. Place the 74HC595 on the Breadboard
Start by inserting the 74HC595 IC onto the breadboard so that the pins on each side are placed in separate rows (opposite halves of the breadboard).
To identify Pin 1, look for the small notch or dot on the IC — Pin 1 is to the left of the notch.
2. Power the Shift Register
- Connect Pin 16 (VCC) to the 5V pin of the Arduino.
- Connect Pin 8 (GND) to the GND of the Arduino.
- Connect Pin 10 (SRCLR) to 5V to keep the shift register enabled.
- Connect Pin 13 (OE) to Arduino pin 9 — this allows you to control output enable (active LOW). If you don’t plan to toggle outputs dynamically, you can also tie it to GND directly.
3. Connect the Control Pins
The 74HC595 uses three Arduino pins for control:
- Pin 11 (SRCLK) → Connect to Arduino pin 12 (Shift register clock).
- Pin 12 (RCLK) → Connect to Arduino pin 10 (Latch pin to transfer data to outputs).
- Pin 14 (SER) → Connect to Arduino pin 11 (Serial data input).
4. Connect the LEDs
- Connect the anodes (positive legs) of the 8 LEDs to the output pins QA to QH (Pins 15, 1, 2, 3, 4, 5, 6, 7 respectively).
- Connect a 220Ω resistor in series with each LED to limit current and prevent damage.
- Connect the cathodes (negative legs) of the LEDs to GND on the Arduino.
Arduino Code
/*
Code to interface 74HC595 SIPO shift register using Arduino UNO
by www.playwithcircuit.com
*/
//Pin connected to SH_CP of 74HC595
int clockPin = 12;
//Pin connected to DS of 74HC595
int dataPin = 11;
//Pin connected to ST_CP of 74HC595
int latchPin = 10;
//Pin connected to OE of 74HC595
int brightnessPin = 9;
//Brightness control variable
int PWM_Value = 0;
void setup() {
//set pins to output so you can control the shift register and initially they should be HIGH
pinMode(latchPin, OUTPUT);
pinMode(clockPin, OUTPUT);
pinMode(dataPin, OUTPUT);
pinMode(brightnessPin, OUTPUT);
digitalWrite(latchPin, HIGH);
digitalWrite(clockPin, HIGH);
digitalWrite(dataPin, HIGH);
analogWrite(brightnessPin, 255);
}
void loop() {
int led_byte = 0x00;
// turn ON all LEDs one by one
for (int i = 0; i < 8; i++) {
// adjust the brightness of LEDs
PWM_Value = (255 - (115 + (20*i)));
analogWrite(brightnessPin, PWM_Value);
led_byte |= (0x01 << i);
// take the latchPin low
digitalWrite(latchPin, LOW);
// shift out the bits:
shiftOut(dataPin, clockPin, MSBFIRST, led_byte);
//take the latch pin high so the LEDs will light up:
digitalWrite(latchPin, HIGH);
// pause before next value:
delay(100);
}
// turn OFF all LEDs one by one
for (int i = 0; i < 8; i++) {
led_byte &= ~(0x01 << i);
// make the latchPin low
digitalWrite(latchPin, LOW);
// shift out the bits:
shiftOut(dataPin, clockPin, MSBFIRST, led_byte);
//make the latch pin high so the LEDs will light up:
digitalWrite(latchPin, HIGH);
// pause before next value
delay(100);
}
}
To learn more checkout: 74HC595 Shift Register Interfacing with Arduino UNO
Top comments (0)