4″ 7-segment/More than one digit/07. DATAOUT to DATAIN
More than one digit · 07 of 11

DATAOUT to DATAIN

A byte does not go to a module. It goes through one. Send a second byte and the first is pushed along into the next module, which is the whole mechanism behind a chain of any length.

The queue

The shift register has eight stages and a bit enters at one end. Clock in a ninth bit and something has to happen to the first one: it falls out of the far end, onto the pin printed (QH) DATAOUT.

Wire that pin to the next module's DATAIN and nothing is lost. It carries on into the next register, which is eight stages of exactly the same thing.

A byte goes through a module, not to it
step 0 of 4
First module holds
Second module holds
Latch pulses
0
One wire, one byte at a time, in the order you send them. Each module’s shift register spills out of its last stage into the next module’s first, so sending a second byte does not address the second module — it pushes the first byte along into it.

Watch the byte for the 7 land in the first module and then get pushed out of it by the byte for the 3. Two shiftOut calls and two modules are loaded; the first byte travelled twice as far as the second.

One latch for the whole row

Look at what the latch and clock do in that drawing: they go straight across the join, untouched, to every module at once. So does the logic rail, and so does the 12 V.

That is why the code for a chain is barely different from the code for one module:

void updateDisplay(const uint8_t *buf) {
  digitalWrite(LAT, LOW);
  for (int i = 0; i < NUM_DIGITS; i++)
    shiftOut(SER, CLK, MSBFIRST, buf[i]);
  digitalWrite(LAT, HIGH);
}

One more module is one more turn of the loop. The latch stays outside it, pulsed once, and every digit in the row changes at the same instant however many of them there are.

Plugging them together

The boards are meant to butt up against each other. Both edges have their seven holes in the same places, so two neighbours line up pin for pin across the seam, and a short length of the male header strip bridges them.

Two display modules laid back-side-up and touching edge to edge, with short black header blocks bridging the five-pin signal rows and the two-pin 12 V rows across the seam, and a ribbon of jumper wires entering the left-hand module's IN edge from off the picture.
Two modules joined at the seam. Only the left-hand board here has wires going to a microcontroller; the right-hand one gets everything through the join.

Turn that over and the two digits sit at their natural spacing with no gap between them, which is the point of joining at the edge rather than with flying leads.

Two chained 4-inch modules seen from the front with their digits lit red, sitting flush against each other so the two digits read as one number, with five ribbon wires running from the right-hand module to a black Arduino-compatible board.
The same pair from the front. Note where the wires come out: the module your board talks to is the one on the right.

How long can it get

Nothing in the protocol has a limit. Every extra module is one more shiftOut before the same single latch.

The real limits are ordinary ones. The 12 V supply has to carry every module in the chain, since they all draw through the join. And the wires between your microcontroller and the first module are carrying a clock, which is the one signal here that would rather be short.

When it does not work

Only the module my wires go to lights up

The link between the two boards is not made. Data leaves on DATAOUT and enters the next board on DATAIN; it does not go back to your microcontroller. Check that the OUT edge of the first is joined to the IN edge of the second, and that both sets of joints are soldered.

The second module shows what the first should

It is doing exactly what it is built to do — you are sending the bytes in the wrong order. The byte sent first ends up furthest down the chain, so the leftmost digit has to go out first. The next article is about nothing else.

Do I need a second 12 V supply for the second module?

No. The 12 V and its ground pass straight across the board from the IN edge to the OUT edge, so joining two modules feeds the second one from the first. What a long chain needs is a supply that can deliver enough current for all of them, not a second supply.

Can I chain modules with wires instead of plugging them together?

Yes, and it is how you space digits apart or bend a display round a corner. Carry all seven connections across — both grounds, the logic rail, the 12 V, clock, latch, and DATAOUT to the next DATAIN — and keep the runs short, because a clock edge on a long unshielded wire is the one signal here that minds.

Where this goes next

The module wired to your board is the right-hand one, and it holds the byte you sent last. That surprises everybody once.

Which module shows the ones

Edit this page — content/books/4-inch-7-segment/data-out-data-in.mdx

Community

Questions about this product

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

Ask a question ↗

4″ 7-Segment LED Display with 74HC595

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