TM1637 display/Why this display/01. Four digits, two wires
Why this display · 01 of 13

Four digits, two wires

Four digits are thirty-two LEDs sharing eight wires, which means only one digit can be lit at any instant. The TM1637 does that juggling itself, so your sketch sends a number once and then forgets about it.

Thirty-two LEDs, twelve wires

Each digit is seven bars and a dot: eight LEDs. Four digits is thirty-two, and a display that brought every one of them out separately would need thirty-three pins.

It does not. The display on this board has twelve pins. Eight of them are the segments — A to G and the point — and every digit shares them. The other four are the commons, one per digit.

One digit at a time
not started
Wires to the display
12
Wires to your board
2 + power
Digits lit at once
The chip does the part that never stops. Eight segment wires serve all four digits, so a display wired straight to a board needs twelve of its pins and a loop that redraws every digit hundreds of times a second, forever. The TM1637 holds the four bytes and runs that loop itself. Your sketch sends a number once and can then go and do something else — or nothing at all.

Sharing is what makes the arithmetic work and also what makes the display awkward. If all four digits are wired to the same eight segment lines, then at any one instant every digit is being told the same pattern. Two digits cannot show different numbers at the same time.

So it does them one at a time

The way out is old and universal: light digit one for a moment with its pattern on the segment lines, then digit two with its pattern, then three, then four, and go round again fast enough that nobody notices. Each digit is actually dark three quarters of the time.

That is called multiplexing, and somebody has to do it. Wired straight to an Arduino, that somebody is your program: twelve pins and a loop that can never pause, because a pause is a visible flicker.

What the chip takes over

The TM1637 on the back of this board does it instead. It holds four bytes — one per digit — and runs the scan itself from its own oscillator, whatever your sketch is doing.

Two things follow, and both matter more than they sound.

Your board talks to it over two wires, not twelve, so a display costs two ordinary digital pins. And your sketch sends a number once. The display keeps showing it through the next delay(1000), through a long Wi-Fi reconnection, through anything — because nothing in your code is holding it up there.

The second one has a sting in it, which is worth knowing this early: a display showing a number is not evidence that your sketch is still running. The chip will happily hold the last thing it was told long after the board that told it has crashed. There is a way to make a display admit that, and it is in when it shows nothing.

When it does not work

Can I just wire the display to my board directly?

Only if you give up twelve pins and write the refresh loop yourself: eight segment lines, four commons, and code that redraws every digit hundreds of times a second forever. That is what the chip on this board is for, and it is why the board exists.

Photographs of the display come out with digits missing

That is the multiplexing, caught in the act. A camera with a short exposure catches one digit lit and the rest dark, because that is genuinely what is happening. Your eye adds them up; a 1/2000 s shutter does not.

The digits flicker when I look away from them

Peripheral vision is faster than central vision, so a scan you cannot see head-on can be visible out of the corner of your eye. There is no setting for this — the scan rate is the chip's own. Lowering the brightness usually makes it less noticeable.

Where this goes next

What actually travels down CLOCK and DATA, and why an I²C scanner will never find this display.

Two wires, but not I²C

Edit this page — content/books/tm1637-display/four-digits-two-wires.mdx

Community

Questions about this product

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

This page covers several products. Choose yours to see the right 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