All articles

    The Shift Register (74HC595): 8 Outputs from Only 3 Pins

    The 74HC595 chip explained for beginners: how it turns serial data into 8 outputs, the DATA, CLOCK and LATCH pins, the complete wiring by pin number, chaining more than one chip with code, a running-LED effect, the current limits per output, controlling brightness with OE, speed with SPI, and the well-known faults.

    Updated 6 min read

    Want to control 16 LEDs when the Arduino Uno doesn't have enough pins? The 74HC595 chip gives you 8 outputs from only 3 pins, and if you chain several chips, you can reach dozens of outputs with the same 3 pins.

    The idea

    The microcontroller sends 8 bits one after another on a single wire, and the chip puts them on 8 outputs at once.

    The data enters bit by bit, and with the latch it appears on 8 outputs at once
    The data enters bit by bit, and with the latch it appears on 8 outputs at once

    Imagine a queue: with each clock pulse, every bit inside the chip moves one step forward, and a new bit enters at the start. After 8 pulses, the queue is filled with the 8 bits you sent. And the bit leaving the end of the queue comes out on Q7' to the next chip.

    The important pins

    PinName in the datasheetFunction
    DATADS / SERThe incoming bit
    CLOCKSH_CP / SRCLKWith each pulse the bit is pushed in
    LATCHST_CP / RCLKA pulse that moves the 8 bits to the outputs at once
    Q0 – Q7—The outputs
    Q7'QH'Output to the next chip
    OE—Output enable, low = active; connect it to ground
    MRSRCLRClear, low = clear; connect it to the supply

    Wiring by pin number (DIP-16)

    Chip pinConnect to
    16 (VCC)5 V + a 100n capacitor to ground
    8 (GND)Ground
    14 (DS)Arduino pin 2
    11 (SH_CP)Pin 3
    12 (ST_CP)Pin 4
    13 (OE)Ground
    10 (MR)5 V
    15, 1–7Q0, and Q1–Q7: each → a resistor → an LED → ground

    Note: Q0 is on pin 15, not next to the others. And Q1 to Q7 are on pins 1 to 7. Where's pin 1? See the IC and pin numbering.

    Why is there a latch?

    Without a latch, the outputs would change with every incoming bit, and you'd see the LEDs flickering as they filled up. The latch lets the chip fill the bits internally first, then output them all at once.

    The code

    const int DATA = 2, CLOCK = 3, LATCH = 4;
    
    void setup() {
      pinMode(DATA, OUTPUT); pinMode(CLOCK, OUTPUT); pinMode(LATCH, OUTPUT);
    }
    
    void loop() {
      digitalWrite(LATCH, LOW);
      shiftOut(DATA, CLOCK, MSBFIRST, 0b10110010);
      digitalWrite(LATCH, HIGH);
      delay(500);
    }

    Each bit in the number 0b10110010 controls an LED. See the number systems article.

    MSBFIRST or LSBFIRST? With MSBFIRST the most significant bit (the leftmost) enters first, so it ends up at Q7. So 0b10000000 lights Q7, and 0b00000001 lights Q0. If the LEDs come out reversed, change it to LSBFIRST.

    A running-LED effect

    void loop() {
      for (int i = 0; i < 8; i++) {
        digitalWrite(LATCH, LOW);
        shiftOut(DATA, CLOCK, MSBFIRST, 1 << i);   // only one LED
        digitalWrite(LATCH, HIGH);
        delay(100);
      }
    }

    1 << i makes a number with only one bit set, at position i. It's the same idea as bitwise operations.

    More than one chip (daisy chain)

    Connect Q7' of the first chip to DATA of the second, and keep CLOCK and LATCH shared. Send two bytes one after another, and you get 16 outputs. And so on for any number.

    void write16(unsigned int v) {
      digitalWrite(LATCH, LOW);
      shiftOut(DATA, CLOCK, MSBFIRST, highByte(v));  // for the second (farther) chip
      shiftOut(DATA, CLOCK, MSBFIRST, lowByte(v));   // for the first chip
      digitalWrite(LATCH, HIGH);
    }

    The byte sent first goes to the farthest chip, because it's pushed through from the first to the second. And with many chips, put a 100n capacitor next to each one, and keep the clock wire short.

    Current limits: important

    • Each output can supply a limited current, and the total current of the whole chip is limited too (about 70 mA on the supply and ground pins according to the datasheet).
    • So 8 LEDs at 20 mA each = 160, more than allowed.
    • The fix: run each LED at a low current (about 5 mA; modern LEDs light well at that), and calculate the resistor from the LED resistor article. Or use transistors or a TPIC6B595 chip for larger loads.

    An example: a red LED (2 V) on 5 V at 5 mA: (5 − 2) ÷ 0.005 = 600 → 680 Ω. And 8 LEDs lit = 40 mA, within the safe limit.

    Note: each LED with its own resistor. One resistor on the common ground of all the LEDs makes the brightness change with the number of LEDs lit.

    Brightness and speed

    • Brightness: instead of connecting the OE pin to ground, connect it to a PWM pin and use analogWrite(9, 255 - level) (because it's active low). That way you control the brightness of all 8 LEDs at once.
    • Speed: shiftOut is relatively slow (about 100 µs per byte). If you need to update a lot, fast (a large matrix), use SPI: connect DATA to MOSI (pin 11) and CLOCK to SCK (pin 13), and the speed is many times higher. See UART, I2C and SPI.

    Uses

    And if you need many inputs instead of outputs, the 74HC165 chip does the reverse.

    Well-known faults

    SymptomUsual cause
    Not a single LED lightsOE is connected to the supply, or MR is connected to ground
    The LEDs light randomlyNo latch, MR left floating, or no capacitor
    The order is reversedMSBFIRST vs LSBFIRST
    Q0 doesn't workConnected to the wrong pin; Q0 is on pin 15
    The chip is hotThe total current exceeds the limit

    FAQ

    Does it work on 3.3 V with an ESP32? Yes, the 74HC595 runs from 2 to 6 V. Power it from 3.3, and the LEDs will be a little dimmer, so reduce the resistor.

    The 74HC595 or the 74HCT595? The HCT is designed to understand a 3.3 V signal while powered from 5. Useful if you want the LEDs on 5 V and control from an ESP32.

    Circuits Nerd
    © 2026 Circuits Nerd. All rights reserved.