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
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 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.
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.
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.
Edit this page — content/books/hc595-segment-led/shift-then-latch.mdx
Questions about this product
See what other owners have asked, and read their solutions.
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.