From a byte to a digit · 03 of 9

Shift, then latch

The 74HC595 takes one bit from DATA on each rising edge of CLOCK and moves the others one place along. Eight edges fill it. The digit does not change until LATCH rises, and then all eight segments change at once.

Two registers in one chip

A digit has eight LEDs: seven segments and a dot. Wired straight to a microcontroller that is eight pins. The 74HC595 does it with three, because it holds two rows of eight bits:

  • the shift register, which fills one bit at a time from DATA, and
  • the storage register, which drives the eight outputs and so the segments.

CLOCK fills the first. LATCH copies the first into the second.

Eight clocks, then one latch
Byte
In the register
0x06
On the digit
0x06
Wires used
3
The digit shows 1, and the register still holds its byte. Run it to send a new one: DATA's first bit is bit 7, the decimal point.

Eight clocks

On each rising edge of CLOCK, the chip reads DATA, puts that bit into the first place, Q0, and moves every other bit one place towards Q7. The bit that was in Q7 falls off the end. After eight edges the eight bits you sent fill the register, the first one sent furthest along.

DATA is only read at the edge. Between edges it can change as it likes, which is how shiftOut works: set DATA, raise CLOCK, lower it, next bit.

One latch

All that time the digit shows the old byte. The outputs only change when LATCH goes from LOW to HIGH: then the whole shift register is copied to the outputs in one step. That is why a sketch writes

digitalWrite(LATCH_PIN, LOW);
shiftOut(DATA_PIN, CLOCK_PIN, MSBFIRST, pattern);
digitalWrite(LATCH_PIN, HIGH);

and why the digit goes from 1 to 2 without passing through anything in between. If LATCH were wired to CLOCK, the outputs would follow the register one edge behind and you would see each bit slide across the segments.

The chip is quick: Nexperia specifies a clock pulse of 15 ns at 4.5 V. No Arduino or MicroPython pin toggles that fast, so there is nothing to slow down.

When it does not work

The segments ripple while the digit changes.

The outputs are following the shift register instead of waiting for the latch. Check LATCH has its own pin, is held LOW while the eight bits go in, and rises once after the last one. Wired to CLOCK, it latches on every edge.

Is this SPI?

It has the same shape, a clock and a data line, and an SPI peripheral can drive it. On this board they are three ordinary pins and the book drives them with shiftOut, which is plenty fast for a digit that changes a few times a second.

Does the digit go dark while the new byte shifts in?

No. The outputs keep showing the old byte the whole time the new one is going in. Only the rising edge on LATCH changes them, which is why there is no flicker between one digit and the next.

Where this goes next

Which bit is which segment, and why a 1 lights one.

One byte, one digit →

Edit this page — content/books/hc595-segment-led/shift-then-latch.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 →