Four-digit seven segment, multiplexed
Four digits on twelve legs: one digit at a time, fast enough that the eye sees all four.
- 12 pins
- 2 settings
- In 1 project
- In 1 lesson
The Four-digit seven segment, multiplexed in brief
What it is, and every setting the properties panel gives it.
The 5641AS is the bare four-digit seven-segment display in starter kits: four 0.56 inch digits on twelve legs, with no driver chip. Eight legs are the segments A to G and DP, each wired to that segment in all four digits, and four are the digit commons DIG1 to DIG4. The 5641AS is common cathode and the 5641BS common anode, a property. On an Uno the usual wiring is the segments on pins 2 to 9 through 220 ohm resistors and the commons on 10 to 13; on an ESP32 it is twelve free GPIOs, and 3.3 volts lights the segments more dimly. Only one digit can show at a time, so the sketch scans them. Mokxi models the 32 segments as LEDs and the eye as two poles of 15 milliseconds: a scan of 50 Hz or faster reads as four steady digits a quarter as bright, a slower one flickers, and changing the segments before switching the old digit off paints a faint ghost. The classic mistakes are resistors on the commons, which dims a digit as more segments light, and a delay() elsewhere in loop() that stalls the scan. Colon variants and brightness spread are not modeled.
- Family
- Displays
- Pins
- 12
- common
- cathode (or anode)
cathode(a 5641AS, digits selected by pulling their common low) oranode(a 5641BS, digits selected by pulling their common high and segments lit by pulling them low).- color
- red (or green, blue, yellow, white)
- the LED color.
12 pins
Named as the editor names them, so a wire lands where you expect it.
- E
- D
- DP
- C
- G
- DIG4
- B
- DIG3
- DIG2
- F
- A
- DIG1
How to use a 4-digit 7-segment display with an Arduino
Segments A to G and DP go to pins 2 to 9, each through its own 220 ohm resistor, and the four digit commons, DIG1 to DIG4, go straight to pins 10 to 13. Each segment leg feeds that segment in all four digits, so only one digit can show at a time: the counter here shows each digit for four milliseconds and moves on, and the eye reads four steady digits.
On this common-cathode 5641AS a digit is on while its common is LOW and a segment lit while its leg is HIGH. Switch every common off before you change the segments, or the old digit shows a faint ghost of the new one; move that line in the sketch and look closely. A delay() anywhere else in loop() stops the scan and leaves one digit lit.
On an ESP32 the same scan runs on twelve free GPIOs; from 3.3 V the segments get less current through the same 220 ohm and look dimmer.
static void show(uint8_t digit, uint8_t pattern) {
for (uint8_t d = 0; d < 4; d++) digitalWrite(DIGIT_PINS[d], HIGH); // all off first
for (uint8_t s = 0; s < 8; s++) {
digitalWrite(SEGMENT_PINS[s], (pattern >> s) & 1 ? HIGH : LOW);
}
digitalWrite(DIGIT_PINS[digit], LOW); // then this one on
delay(4);
}What is true about the Four-digit seven segment, multiplexed, here
In its help article’s own words: what the simulation gets right, and where it stops.
Modeled
Each segment is the same diode as the LED. A common leg carries the current of every segment lit on it, which is eight segments' worth for an "8." and more than a microcontroller pin should sink: the textbook circuit puts a transistor on each common, and the part will tell you the current if you probe it. Put the resistors on the segment legs, not the commons, or the digit dims as more segments come on.
Not modeled
The colon and apostrophe some variants have. Segment-to-segment brightness spread.
From Four-digit seven segment display, in full.
See the Four-digit seven segment, multiplexed in a project
One built-in project uses it. It opens in the editor, already wired.
Where it turns up in a lesson
One lesson places it in its own circuit.
The boards it is shown on
This board has a built-in project with the Four-digit seven segment, multiplexed in it.
Arduino libraries for the Four-digit seven segment, multiplexed
Built in, so the sketch compiles with nothing to install. Each page has the calls, the wiring and an example to run.
The rest of the bench
Every one of these is drawn and simulated the same way.
Wire up the Four-digit seven segment, multiplexed
Open the editor and push it into the breadboard. It is free, and it runs on your own machine.