Overview
The 74HC595 takes eight bits one at a time on a data pin, clocked by a second pin, then copies them to its eight outputs when a third (latch) pin rises. Three Uno pins give eight outputs, and chips can be chained for more.
You will need
- Arduino Uno R3
- 74HC595 (DIP-16)
- 8 LEDs
- 8 × 1 kΩ resistors
- 0.1 µF ceramic capacitor
- Breadboard and jumper wires
Wiring
| Uno pin | Connects to | Notes |
|---|---|---|
| 11 | 74HC595 pin 14 (DS, serial data) | |
| 12 | 74HC595 pin 11 (SHCP, shift clock) | |
| 8 | 74HC595 pin 12 (STCP, latch) | |
| 5V | Pin 16 (VCC) and pin 10 (MR, active-low reset) | Keep MR HIGH |
| GND | Pin 8 (GND) and pin 13 (OE, active-low output enable) | Keep OE LOW |
| — | Q0–Q7 (pins 15, 1–7) → 1 kΩ → LED anode; LED cathodes to GND | |
| — | 0.1 µF capacitor between pins 16 and 8 | Close to the chip |
Current
The 74HC595's outputs are meant for a few milliamps each and about 70 mA for the whole chip. Use 1 kΩ resistors (about 3 mA per LED) so all eight can be on at once. For a seven-segment display, put the resistors between the outputs and the segments, just like with direct pins.
The sketch
const int DATA_PIN = 11; // 74HC595 DS
const int CLOCK_PIN = 12; // 74HC595 SHCP
const int LATCH_PIN = 8; // 74HC595 STCP
void writeShiftRegister(byte value) {
digitalWrite(LATCH_PIN, LOW);
shiftOut(DATA_PIN, CLOCK_PIN, MSBFIRST, value);
digitalWrite(LATCH_PIN, HIGH); // outputs update on this rising edge
}
void setup() {
pinMode(DATA_PIN, OUTPUT);
pinMode(CLOCK_PIN, OUTPUT);
pinMode(LATCH_PIN, OUTPUT);
writeShiftRegister(0);
}
void loop() {
// One LED at a time, Q0 to Q7
for (int bit = 0; bit < 8; bit++) {
writeShiftRegister((byte)(1 << bit));
delay(150);
}
// Count 0 to 255 in binary
for (int value = 0; value < 256; value++) {
writeShiftRegister((byte)value);
delay(60);
}
}How the code works
With MSBFIRST the first bit sent ends up on Q7, so bit 0 of the value appears on
Q0. Holding the latch LOW while shifting keeps the LEDs from flickering through intermediate patterns. To chain
a second chip, connect Q7' (pin 9) of the first to DS of the second, share clock and latch, and call
shiftOut() twice.
What you should observe
- A single light runs from Q0 to Q7, then the LEDs count in binary.
- Nothing lights: check OE is at GND and MR is at 5V. Random patterns at power-up are normal until the first write.