Preview build — page text is a draft awaiting human review. Code badges come from real compiles. The flasher is real but not yet hardware-tested; the Playground is still a preview.

74HC595 shift register with Arduino Nano — 8 LEDs from 3 pins via SPI

Wire a 74HC595 to an Arduino Nano on the hardware SPI pins (D11, D13) with a latch on D10, and drive eight LEDs as a scanner — faster than shiftOut().

Arduino C++Verified — core avr 1.8.8, 3 Nov 2026Compile-only

Community draft — report a mistake

When the Nano runs out of pins, a ₹15 74HC595 adds eight outputs from three wires. It is how LED bar graphs, 7-segment displays and relay boards with many channels are usually driven.

Instead of the usual shiftOut() this guide uses the Nano’s hardware SPI — data on D11, clock on D13, latch on D10 — which is far faster and leaves the CPU free. The sketch runs a back-and-forth scanner across eight LEDs.

Wiring

Arduino NanoOnly the pins used are shown · 5 V logic74HC595 8-bit shift register (DIP-16)D135VGNDD11D10VCCGNDDSSH_CPST_CPOEMRQ0 → 220 Ω → LED 1 → GNDQ1 → 220 Ω → LED 2 → GNDQ2 → 220 Ω → LED 3 → GNDQ3 → 220 Ω → LED 4 → GNDQ4 → 220 Ω → LED 5 → GNDQ5 → 220 Ω → LED 6 → GNDQ6 → 220 Ω → LED 7 → GNDQ7 → 220 Ω → LED 8 → GNDQ7S (not connected)
Also needed: 8 LEDs and 8 × 220 Ω resistors, 100 nF ceramic capacitor.
Every connection
Arduino Nano74HC595 8-bit shift register (DIP-16)WireNotes
—Q0—To 220 Ω → LED 1 → GND (not drawn)
—Q1—To 220 Ω → LED 2 → GND (not drawn)
—Q2—To 220 Ω → LED 3 → GND (not drawn)
—Q3—To 220 Ω → LED 4 → GND (not drawn)
—Q4—To 220 Ω → LED 5 → GND (not drawn)
—Q5—To 220 Ω → LED 6 → GND (not drawn)
—Q6—To 220 Ω → LED 7 → GND (not drawn)
—Q7—To 220 Ω → LED 8 → GND (not drawn)
5VVCCred100 nF capacitor from VCC to GND, right at the chip.
GNDGNDblack
D11DSgreenMOSI
D13SH_CPyellowSCK
D10ST_CPpurpleLatch
GNDOEblackOutputs always on. Wire to a PWM pin instead to dim all LEDs.
5VMRredReset held inactive.

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

  • DS and SH_CP on D11 and D13 let the Nano’s hardware SPI clock out a byte in about 2 µs — roughly 50× faster than shiftOut(). The latch can be any pin; D10 is used because it must stay an output for SPI anyway.
  • D13 is also the on-board LED, so it flickers with the clock. Harmless.
  • The 74HC595 can source about 6 mA per output and 70 mA in total. 220 Ω LEDs are fine; relays and motors need a ULN2803 after it.
  • Chain more chips by wiring Q7S to the next DS and sharing SH_CP/ST_CP; then send one byte per chip before latching.
  • Pin names differ by maker (SER/SRCLK/RCLK on TI datasheets). See the component page for the mapping.

Code

shift595-nano.inoArduino C++Open in PlaygroundOpen in PlaygroundFlash
// 74HC595 shift register on an Arduino Nano driving 8 LEDs with hardware SPI (fast, 3 pins).
// DS → D11 (MOSI), SH_CP → D13 (SCK), ST_CP → D10 (latch), OE → GND, MR → 5V, VCC → 5V, GND → GND.
// Q0-Q7 each → 220 Ω → LED → GND.
#include <SPI.h>

const uint8_t LATCH_PIN = 10;

void write595(uint8_t bits) {
  digitalWrite(LATCH_PIN, LOW);
  SPI.transfer(bits);              // Q7 gets the first bit out (MSB first)
  digitalWrite(LATCH_PIN, HIGH);   // rising edge on ST_CP copies the byte to Q0-Q7
}

void setup() {
  Serial.begin(115200);
  pinMode(LATCH_PIN, OUTPUT);
  SPI.begin();
  SPI.beginTransaction(SPISettings(4000000, MSBFIRST, SPI_MODE0));
  write595(0);
  Serial.println(F("Scanner pattern on Q0-Q7"));
}

void loop() {
  for (int8_t i = 0; i < 8; i++) {   // Q0 → Q7
    write595(1 << i);
    delay(70);
  }
  for (int8_t i = 6; i > 0; i--) {   // and back
    write595(1 << i);
    delay(70);
  }
  static uint8_t rounds = 0;
  if (++rounds % 10 == 0) {
    Serial.print(F("Rounds: "));
    Serial.println(rounds);
  }
}

Expected serial output

Serial Monitor · 115200Output
Scanner pattern on Q0-Q7
Rounds: 10
Rounds: 20

Common errors

All LEDs on or random

MR floating or OE not grounded. Both must be tied, as in the table.

Pattern runs backwards

Change MSBFIRST to LSBFIRST, or wire the LEDs in the other order.

↑↓ to move · Enter to open