The 74HC595 turns three Uno pins into eight outputs. The Uno has only about 18 usable I/O pins, so this chip is how LED bar graphs, 7-segment displays and large relay banks fit on one board. Several chips can be chained on the same three wires.
The Uno shifts a byte in one bit at a time on DS (D11) with clock pulses on SH_CP (D12). A pulse on the latch, ST_CP (D8), then copies all eight bits to the outputs at once. Two control pins need fixed levels: OE to GND keeps the outputs on, and MR to 5V keeps the register out of reset.
The sketch runs a light back and forth across the eight LEDs. It then counts in binary, printing each pattern so you can check it against the LEDs.
Wiring
| Arduino Uno R3 | 74HC595 8-bit shift register (DIP-16) | Wire | Notes |
|---|---|---|---|
| — | Q0 | — | To LED 1 via 470 Ω to GND (not drawn) |
| — | Q1 | — | To LED 2 via 470 Ω (not drawn) |
| — | Q2 | — | To LED 3 via 470 Ω (not drawn) |
| — | Q3 | — | To LED 4 via 470 Ω (not drawn) |
| — | Q4 | — | To LED 5 via 470 Ω (not drawn) |
| — | Q5 | — | To LED 6 via 470 Ω (not drawn) |
| — | Q6 | — | To LED 7 via 470 Ω (not drawn) |
| — | Q7 | — | To LED 8 via 470 Ω (not drawn) |
| 5V | VCC | red | Pin 16. Put a 100 nF capacitor from VCC to GND right at the chip. |
| GND | GND | black | Pin 8. |
| D11 | DS | green | Serial data in (pin 14). |
| D12 | SH_CP | blue | Shift clock (pin 11). |
| D8 | ST_CP | yellow | Latch / storage clock (pin 12). |
| GND | OE | black | Pin 13, active-LOW output enable. Wire it to a PWM pin instead to dim all 8 LEDs at once. |
| 5V | MR | red | Pin 10, active-LOW reset — keep HIGH. |
2–6 V part, 5 V board. Power it from the same voltage as your board: 3.3 V on ESP32 and Pico, 5 V on Uno. At 5 V the 74HC595 needs about 3.15 V for a HIGH, so a 3.3 V board driving a 5 V-powered chip is marginal — use a 74HCT595 at 5 V for that.
Board quirks
- The chip is rated 70 mA total through VCC/GND. With 470 Ω resistors each LED takes about 6 mA, so all 8 on is about 50 mA. Smaller resistors look brighter but overheat the chip when every output is on.
shiftOut()works on any pins. The data and clock here are D11 and D12; D13 is left alone because the on-board LED flickers with the clock. For speed you can use hardware SPI (D11 + D13) instead.- Chain more chips by wiring Q7S (pin 9) of the first to DS of the next, sharing clock and latch. Then send one byte per chip, last chip first.
- Pin names vary by maker: NXP prints DS/SH_CP/ST_CP/Q7S, TI prints SER/SRCLK/RCLK/QH′. They are the same pins.
Code
// 74HC595 shift register on an Arduino Uno R3: 8 LEDs from 3 pins.
// DS → D11, ST_CP (latch) → D8, SH_CP (clock) → D12. OE → GND, MR → 5V, VCC → 5V, GND → GND.
// Q0–Q7 → LED + 470 Ω resistor each → GND.
const uint8_t DATA_PIN = 11, LATCH_PIN = 8, CLOCK_PIN = 12;
void writeByte(uint8_t value) {
digitalWrite(LATCH_PIN, LOW);
shiftOut(DATA_PIN, CLOCK_PIN, MSBFIRST, value); // Q7 gets the first bit sent
digitalWrite(LATCH_PIN, HIGH); // outputs change together on this edge
}
void setup() {
pinMode(DATA_PIN, OUTPUT);
pinMode(LATCH_PIN, OUTPUT);
pinMode(CLOCK_PIN, OUTPUT);
writeByte(0);
Serial.begin(9600);
Serial.println(F("74HC595: running light, then a binary counter"));
}
void loop() {
for (uint8_t i = 0; i < 8; i++) { // Q0 → Q7
writeByte(1 << i);
delay(80);
}
for (int8_t i = 6; i > 0; i--) { // and back
writeByte(1 << i);
delay(80);
}
for (uint16_t n = 0; n < 256; n += 17) {
writeByte(n);
Serial.print(F("Binary "));
for (int8_t b = 7; b >= 0; b--) Serial.print((n >> b) & 1);
Serial.print(F(" = "));
Serial.println(n);
delay(300);
}
}// 74HC595 shift register on an Arduino Uno R3: 8 LEDs from 3 pins.
// DS → D11, ST_CP (latch) → D8, SH_CP (clock) → D12. OE → GND, MR → 5V, VCC → 5V, GND → GND.
// Q0–Q7 → LED + 470 Ω resistor each → GND.
const uint8_t DATA_PIN = 11, LATCH_PIN = 8, CLOCK_PIN = 12;
void writeByte(uint8_t value) {
digitalWrite(LATCH_PIN, LOW);
shiftOut(DATA_PIN, CLOCK_PIN, MSBFIRST, value); // Q7 gets the first bit sent
digitalWrite(LATCH_PIN, HIGH); // outputs change together on this edge
}
void setup() {
pinMode(DATA_PIN, OUTPUT);
pinMode(LATCH_PIN, OUTPUT);
pinMode(CLOCK_PIN, OUTPUT);
writeByte(0);
Serial.begin(9600);
Serial.println(F("74HC595: running light, then a binary counter"));
}
void loop() {
for (uint8_t i = 0; i < 8; i++) { // Q0 → Q7
writeByte(1 << i);
delay(80);
}
for (int8_t i = 6; i > 0; i--) { // and back
writeByte(1 << i);
delay(80);
}
for (uint16_t n = 0; n < 256; n += 17) {
writeByte(n);
Serial.print(F("Binary "));
for (int8_t b = 7; b >= 0; b--) Serial.print((n >> b) & 1);
Serial.print(F(" = "));
Serial.println(n);
delay(300);
}
}Expected serial output
74HC595: running light, then a binary counter
Binary 00000000 = 0
Binary 00010001 = 17
Binary 00100010 = 3474HC595: running light, then a binary counter Binary 00000000 = 0 Binary 00010001 = 17 Binary 00100010 = 34
Common errors
LEDs light in a random pattern and stay that way
The latch (ST_CP) isn’t toggling — check it is on D8. Without the latch edge the outputs never update.
Nothing lights at all
OE is floating or HIGH (outputs off), or MR is LOW (register held in reset). Tie OE to GND and MR to 5V.
LEDs flicker or show ghost patterns
Missing the 100 nF decoupling capacitor, or long loose jumpers on the clock line.