PinoutSearch

Drive 8 LEDs from 3 Pins (74HC595 + Arduino)

Use a 74HC595 shift register to control 8 LEDs with just 3 Arduino pins. Learn shiftOut and binary.

Beginner30 min

What you need

Wiring

Hover a pin or a wire to trace the connection.

Code

shift_register.ino
// Count 0–255 in binary across 8 LEDs using a 74HC595 shift register.
const int dataPin  = 11; // DS
const int clockPin = 12; // SH_CP
const int latchPin = 8;  // ST_CP

void setup() {
  pinMode(dataPin, OUTPUT);
  pinMode(clockPin, OUTPUT);
  pinMode(latchPin, OUTPUT);
}

void loop() {
  for (int n = 0; n < 256; n++) {
    digitalWrite(latchPin, LOW);
    shiftOut(dataPin, clockPin, MSBFIRST, n); // push one byte
    digitalWrite(latchPin, HIGH);             // latch -> outputs update
    delay(200);
  }
}

Steps

  1. Power the 595: VCC + MR to 5V, GND + OE to GND.
  2. Wire data → D11, clock → D12, latch → D8.
  3. Wire Q0–Q7 each to an LED through a 220Ω resistor; all cathodes to GND.
  4. Upload — the LEDs count up in binary.