Running out of digital output pins on your Arduino? The 74HC595 shift register is the classic solution. With this single IC costing less than ₹10, you can control 8 output pins using just 3 Arduino pins — and you can daisy-chain multiple 74HC595s to get 16, 24, or 32 outputs from those same 3 pins. In this complete guide to using the arduino 74hc595 shift register, you will learn the theory, the wiring, the code, and real-world applications like LED matrices and 7-segment displays.
How the 74HC595 Shift Register Works
The 74HC595 is an 8-bit Serial-In, Parallel-Out (SIPO) shift register with an output latch. Understanding three key concepts demystifies its operation completely:
- Serial input: Data bits are fed one at a time on the DS (Data) pin, synchronised with pulses on the SHCP (Shift Clock) pin.
- Shift register: Inside the IC, 8 flip-flops are connected in a chain. Each clock pulse shifts the bits one position along the chain — bit 7 falls into the latch (or out via QH’ to the next IC in the chain).
- Output latch: After all 8 bits are shifted in, a pulse on the STCP (Storage/Latch Clock) pin simultaneously transfers all 8 bits to the output pins (Q0–Q7). This prevents flickering during bit shifting.
The beauty of this design is that you can keep sending clock pulses without disturbing the outputs — the latch only updates when you explicitly pulse STCP. This makes the 74HC595 ideal for applications where simultaneous output updates are important, such as digit displays and LED strips.
74HC595 Pinout and Pin Functions
The 74HC595 comes in a standard 16-pin DIP package. Here is what each pin does:
| Pin | Name | Function |
|---|---|---|
| 1–7, 15 | Q0–Q7 | 8 parallel outputs |
| 8 | GND | Ground |
| 9 | QH’ | Serial out (to DS of next IC for daisy-chaining) |
| 10 | SRCLR | Shift register clear (active LOW — tie to VCC normally) |
| 11 | SHCP | Shift register clock |
| 12 | STCP | Storage (latch) clock |
| 13 | OE | Output enable (active LOW — tie to GND to enable outputs) |
| 14 | DS | Serial data input |
| 16 | VCC | Power supply (2 V–6 V, use 5 V with Arduino Uno) |
Critical note: Always tie SRCLR (pin 10) to VCC and OE (pin 13) to GND. If SRCLR is LOW, all shift register bits clear to 0. If OE is HIGH, all outputs go to high-impedance and appear as if they are not connected.
Wiring the 74HC595 to Arduino
For a basic 8-LED demonstration, you need: one 74HC595, eight LEDs, eight 220Ω resistors, and jumper wires.
Connections
- Arduino pin 11 → DS (pin 14) — Data
- Arduino pin 12 → STCP (pin 12) — Latch
- Arduino pin 13 → SHCP (pin 11) — Clock
- Arduino 5V → VCC (pin 16) and SRCLR (pin 10)
- Arduino GND → GND (pin 8) and OE (pin 13)
- Q0–Q7 (pins 15, 1–7) → 220Ω resistors → LED anodes → GND
Place a 100 nF bypass capacitor between VCC and GND as close to the IC as possible. This absorbs switching noise and prevents glitches on the outputs — a small detail that makes a big difference in reliability.
Basic Code: Controlling 8 LEDs
Arduino’s built-in shiftOut() function makes 74HC595 control straightforward. Here is a complete, annotated sketch:
const int dataPin = 11; // DS
const int latchPin = 12; // STCP
const int clockPin = 13; // SHCP
void setup() {
pinMode(dataPin, OUTPUT);
pinMode(latchPin, OUTPUT);
pinMode(clockPin, OUTPUT);
}
void sendByte(byte data) {
digitalWrite(latchPin, LOW); // Disable latch (freeze outputs)
shiftOut(dataPin, clockPin, MSBFIRST, data); // Shift 8 bits
digitalWrite(latchPin, HIGH); // Pulse latch (update outputs)
}
void loop() {
// Light each LED one at a time
for (int i = 0; i < 8; i++) {
sendByte(1 << i); // Bit-shift to set one bit at a time
delay(150);
}
// Light all LEDs
sendByte(0xFF);
delay(500);
// Turn all off
sendByte(0x00);
delay(500);
}
The MSBFIRST parameter tells shiftOut() to send the most significant bit first (bit 7 → Q7, bit 0 → Q0). Use LSBFIRST if your wiring reverses the output order.
Using SPI for Faster Output
For time-critical applications, replace shiftOut() with hardware SPI. The 74HC595 is compatible with SPI mode 0 (CPOL=0, CPHA=0). Hardware SPI on an Arduino Uno can clock data at 8 MHz — roughly 100× faster than software shiftOut().
#include <SPI.h>
void sendByteSPI(byte data) {
digitalWrite(latchPin, LOW);
SPI.transfer(data);
digitalWrite(latchPin, HIGH);
}
Daisy-Chaining Multiple 74HC595s
Connect pin QH’ (pin 9) of the first 74HC595 to pin DS (pin 14) of the second. Share the STCP and SHCP lines between all ICs. This way, shiftOut() called twice (or SPI.transfer() called twice) sends 16 bits — 8 bits to each IC simultaneously when the latch is released.
void send2Bytes(byte data1, byte data2) {
digitalWrite(latchPin, LOW);
shiftOut(dataPin, clockPin, MSBFIRST, data2); // Second IC
shiftOut(dataPin, clockPin, MSBFIRST, data1); // First IC
digitalWrite(latchPin, HIGH);
}
Note that data flows through the chain: the first byte you send ends up in the last IC. Think of it like a queue — the first byte in is pushed to the end. Always send the data for the last IC in the chain first.
With three 74HC595s, you control 24 outputs from 3 Arduino pins. Four ICs give you 32 outputs — more than an Arduino Mega — all from the same 3 pins.
Project: 4-Digit 7-Segment Display Driver
A common 4-digit 7-segment display needs 7 segment lines plus a decimal point (8 signals) and 4 digit-select lines — 12 wires total. Using two daisy-chained 74HC595s, you can drive all of this from 3 Arduino pins.
Wiring Plan
- First 74HC595 Q0–Q7 → segments a through dp (with 220Ω resistors)
- Second 74HC595 Q0–Q3 → digit cathodes D1–D4 (common cathode display with NPN transistors for each digit)
Multiplexing
Since a 4-digit display uses multiplexing, your loop refreshes each digit at >100 Hz so the eye perceives all four digits lit simultaneously:
const byte segmentCodes[] = {
0b00111111, // 0
0b00000110, // 1
/* ... 2-9 ... */
};
void displayDigit(int position, int digit) {
byte digitSelect = ~(1 << position); // Active LOW
byte segData = segmentCodes[digit];
send2Bytes(segData, digitSelect);
delay(2); // 2ms per digit = ~125 Hz refresh
send2Bytes(0x00, 0xFF); // Blank before next digit
}
Project: 8×8 LED Matrix Controller
An 8×8 LED matrix has 64 LEDs arranged in 8 rows × 8 columns. Driving it directly requires 16 pins. With two 74HC595s, you need only 3 Arduino pins to scan all 64 LEDs.
Connection Strategy
- First IC: Q0–Q7 → column anodes (positive)
- Second IC: Q0–Q7 → row cathodes via ULN2003 (for sufficient current sink)
Scrolling Text
Store each character as an 8-byte bitmap array. To scroll text, maintain a display buffer and rotate it one column per frame at 30 fps. The 74HC595’s fast latch update makes smooth scrolling easily achievable even with software SPI.
Tips, Troubleshooting and Best Practices
- Decoupling capacitor: Always place a 100 nF capacitor between VCC and GND near the IC. Without it, switching noise can cause random bit errors in the shift register.
- Current limit: Each output pin can source/sink up to 35 mA, but the total package dissipation limits you to 70 mA across all outputs. Use 470Ω resistors instead of 220Ω if you have many LEDs on simultaneously.
- LEDs all flickering: Check that OE (pin 13) is tied solidly to GND, not floating. A floating OE causes erratic output enable behaviour.
- Wrong bit order: If your LEDs are mirrored, swap
MSBFIRSTforLSBFIRSTinshiftOut(). - Outputs not changing: Ensure you pulse STCP (latch) HIGH after shifting. The outputs only update on the rising edge of STCP — a missing latch pulse is the most common beginner mistake.
- Speed: Software
shiftOut()runs at ~150 kHz. For animations or displays requiring fast refresh, switch to hardware SPI (up to 8 MHz on Uno).
Frequently Asked Questions
How many 74HC595s can I daisy-chain together?
Theoretically unlimited from a digital logic standpoint. Practically, signal integrity degrades as the chain lengthens. With standard 5 V logic and reasonable PCB layout, chains of 8–16 ICs work reliably. For longer chains, use a buffer/repeater IC every 8 stages or switch to SPI with a higher drive-strength output.
Can the 74HC595 control motors or relays directly?
Not directly. The 74HC595 outputs are rated at 35 mA maximum per pin, which is enough to drive LEDs and logic-level inputs. For motors or relays, use the shift register outputs to control transistors (NPN/MOSFET) or a ULN2003 Darlington array, which can handle much higher currents.
What is the difference between 74HC595 and 74HC165?
The 74HC595 is a Serial-In Parallel-Out (SIPO) shift register used to expand outputs. The 74HC165 is a Parallel-In Serial-Out (PISO) shift register used to expand inputs. Use the 595 to add more output pins and the 165 to add more input pins. They are often used together.
Why does my 74HC595 get warm?
If the IC gets noticeably warm, you are likely exceeding the total package power dissipation. Calculate total LED current: if all 8 LEDs draw 20 mA each, that is 160 mA total — more than double the safe limit. Increase your current-limiting resistors, or split the load across two 74HC595s.
Can I use the 74HC595 at 3.3 V with an Arduino Nano 33?
Yes. The HC-series (not HCT) operates from 2 V to 6 V. At 3.3 V the output drive is slightly lower (22 mA vs 35 mA at 5 V), but perfectly adequate for LED and logic applications. HCT series requires at least 4.5 V and should not be used with 3.3 V systems.
Ready to expand your project? Browse our complete selection of Arduino boards, ICs, and electronics components at Zbotic. Free shipping on orders above ₹999 across India.
Add comment