TK53SPIbeginner

74HC595 Segment LED

Segment digits driven through a shift register: three pins for eight outputs, and the trick worth learning once because it applies to everything.

Comes in this kit — not sold separately

Specifications

Type7-segment display with 74HC595 shift register
InterfaceThree wires: data, clock, latch
Outputs8 per register, chainable
Supply voltage3.3 V or 5 V

What it is

A shift register turns three pins into eight. You clock bits in one at a time, then pulse the latch and all eight outputs change at once.

The reason to learn it on a display is that the result is visible: get the bit order wrong and you see it immediately in which segments light. But the technique is general — the same chip drives relays, LEDs, anything that needs more outputs than the board has pins. Chain two and three pins drive sixteen outputs.

The latch is the part people skip. Without it the outputs change as the bits shift through, so the display flickers through garbage on every update. Latch after the last bit and the change is atomic.

shiftOut() does the clocking in one call, which is fine for a display and too slow for anything that needs speed. SPI does the same thing in hardware.

74HC595 Segment LED — front
Front
74HC595 Segment LED — back
Back
74HC595 Segment LED — side
Side

Pinout

  • GND (negative): Like the negative terminal (-) of a battery, connect to the control board's GND
  • VCC (positive): Like the positive terminal (+) of a battery, connect to the control board's 3.3V or 5V (this module supports both 3.3V and 5V)
  • NC (no connection): No actual circuit connection, included for unified interface, can be left unconnected
  • LATCH (latch): Data latch signal, connect to the control board's digital pin (e.g. Arduino D8 or Pico GPIO 2)
  • CLOCK (clock): Shift clock signal, connect to the control board's digital pin (e.g. Arduino D12 or Pico GPIO 3)
  • DATA (data): Serial data input, connect to the control board's digital pin (e.g. Arduino D11 or Pico GPIO 4)

Wiring

74HC595 Segment LED wiring

  1. GND → Control board GND
  2. VCC → Control board 3.3V or 5V
  3. LATCH → Control board digital pin (e.g. D8)
  4. CLOCK → Control board digital pin (e.g. D12)
  5. DATA → Control board digital pin (e.g. D11)

Example

// Pin number: change these to match your wiring
#define LATCH_PIN 8   // Arduino digital pin connected to LATCH (e.g. D8)
#define CLOCK_PIN 12  // Arduino digital pin connected to CLOCK (e.g. D12)
#define DATA_PIN 11   // Arduino digital pin connected to DATA (e.g. D11)

// 7-segment display segment code table (common anode, numbers 0-9)
byte digitPatterns[10] = {
  0b11111100,  // 0
  0b01100000,  // 1
  0b11011010,  // 2
  0b11110010,  // 3
  0b01100110,  // 4
  0b10110110,  // 5
  0b10111110,  // 6
  0b11100000,  // 7
  0b11111110,  // 8
  0b11110110   // 9
};

void setup() {
  // Initialize pin modes
  pinMode(LATCH_PIN, OUTPUT);
  pinMode(CLOCK_PIN, OUTPUT);
  pinMode(DATA_PIN, OUTPUT);
  
  // Start serial for debugging (9600 baud)
  Serial.begin(9600);
  
  Serial.println("74HC595 7-segment display program started");
  Serial.println("Cycling through 0-9");
}

void loop() {
  // Cycle through 0-9
  for (int i = 0; i < 10; i++) {
    displayDigit(i);
    Serial.print("Display number: ");
    Serial.println(i);
    delay(1000);  // Switch number every second
  }
}

// Display digit function
void displayDigit(int digit) {
  if (digit < 0 || digit > 9) return;  // Check range
  
  // Latch pin LOW, ready to receive data
  digitalWrite(LATCH_PIN, LOW);
  
  // Send data through shift register
  shiftOut(DATA_PIN, CLOCK_PIN, LSBFIRST, digitPatterns[digit]);
  
  // Latch pin HIGH, output data to display
  digitalWrite(LATCH_PIN, HIGH);
}
74HC595 Segment LED running on an Arduino Uno

When it doesn’t work

The segments light in the wrong order.
Bit order. `shiftOut` takes MSBFIRST or LSBFIRST — try the other one before rewiring anything.
The display flickers while updating.
The latch pin is being pulsed too early, or not at all. Shift all eight bits first, then latch once.
Only some segments ever light.
Common-anode versus common-cathode. Invert the byte and see if it comes right.

Edit this page — content/modules/hc595-segment-led.mdx

Community

Questions about this product

See what other owners have asked, and read their solutions.

Ask a question ↗

74HC595 Segment LED

Loading discussions…

Discuss this article

Ask about this page. The answer stays here, on the page it belongs to, for whoever hits the same wall next.

Browse Modules and blocks on the forum