How-to · Beginner · 3 min read
7-Segment Displays
Common Anode vs Cathode, TM1637 and MAX7219
By Geekobot Learning Team · Updated 24 Oct 2026
On this page
A 7-segment display is seven LEDs (plus a decimal point) arranged as a figure 8. In a common-cathode display all cathodes share one pin and you drive each segment high; in common-anode they share the positive pin and you drive segments low. Each segment needs its own resistor. For clocks and counters, a TM1637 4-digit module needs only two pins and a small library.
Key specs at a glance
- Segments
- a to g plus DP; 10 pins on a single digit
- Forward voltage
- About 2 V red, 3 V blue/white
- Per-segment current
- 5 to 15 mA, resistor 220 to 470 Ω at 5 V
- TM1637 module
- 4 digits, 2 wires (CLK, DIO), 3.3 to 5 V
- MAX7219 module
- Up to 8 digits or an 8x8 matrix, SPI, 5 V
- Multiplexing
- Needed when driving several bare digits from few pins
Common anode vs common cathode
Find the common pin (usually the middle pin on each row of a single digit). Set a multimeter to diode test: with the black lead on the middle pin and red on any other pin, a lit segment means common cathode; if it lights with the red lead on the middle pin, it is common anode. Code for one type is the inverse of the other, which is why a wrong assumption shows every segment except the ones you wanted.
Single-digit pinout (typical 0.56 inch)
| Pin | Segment |
|---|---|
| 1 | e |
| 2 | d |
| 3 | common |
| 4 | c |
| 5 | DP |
| 6 | b |
| 7 | a |
| 8 | common |
| 9 | f |
| 10 | g |
- 1
- e
- 2
- d
- 3
- common
- 4
- c
- 5
- DP
- 6
- b
- 7
- a
- 8
- common
- 9
- f
- 10
- g
Driving one digit from an Arduino
Connect segments a to g to pins 2 to 8 through 330 Ω resistors each, and the common to GND (common cathode). Digits are patterns of segments:
const int seg[7] = {2, 3, 4, 5, 6, 7, 8}; // a b c d e f g
const byte digits[10] = {
0b0111111, 0b0000110, 0b1011011, 0b1001111, 0b1100110,
0b1101101, 0b1111101, 0b0000111, 0b1111111, 0b1101111 }; // bit0 = a ... bit6 = g
void setup() { for (int p : seg) pinMode(p, OUTPUT); }
void show(int n) {
for (int i = 0; i < 7; i++) digitalWrite(seg[i], bitRead(digits[n], i)); // invert for common anode
}
void loop() {
for (int n = 0; n < 10; n++) { show(n); delay(500); }
}The easy way: TM1637 4-digit module
The TM1637 chip handles all the multiplexing and brightness; you send numbers over two wires. Install the TM1637Display library (Avishay Orpaz).
#include <TM1637Display.h>
TM1637Display display(2, 3); // CLK, DIO
void setup() {
display.setBrightness(5); // 0 to 7
}
void loop() {
display.showNumberDecEx(1245, 0b01000000, true); // 12:45 with the colon
delay(1000);
}TM1637 vs MAX7219 vs bare digits
| Option | Pins used | Digits | Choose it for |
|---|---|---|---|
| Bare single digit | 8 | 1 | Learning how segments work |
| Bare 4-digit multiplexed | 12 | 4 | Teaching multiplexing; otherwise avoid |
| TM1637 module | 2 | 4 (6 on some) | Clocks, counters, temperature readouts |
| MAX7219 module | 3 (SPI) | 8 digits or 8x8 matrix, chainable | Scoreboards, scrolling text, large readouts |
| HT16K33 backpack | 2 (I2C) | 4 digits, 14-segment too | I2C-only pin budgets |
- Bare single digit
- Pins used:
- 8
- Digits:
- 1
- Choose it for:
- Learning how segments work
- Bare 4-digit multiplexed
- Pins used:
- 12
- Digits:
- 4
- Choose it for:
- Teaching multiplexing; otherwise avoid
- TM1637 module
- Pins used:
- 2
- Digits:
- 4 (6 on some)
- Choose it for:
- Clocks, counters, temperature readouts
- MAX7219 module
- Pins used:
- 3 (SPI)
- Digits:
- 8 digits or 8x8 matrix, chainable
- Choose it for:
- Scoreboards, scrolling text, large readouts
- HT16K33 backpack
- Pins used:
- 2 (I2C)
- Digits:
- 4 digits, 14-segment too
- Choose it for:
- I2C-only pin budgets
Try it: LED resistor calculator
Change the values and the diagram and results update as you type.
Common mistakes to avoid
- Driving a display without segment resistors.
- Mixing up common anode and common cathode.
- Using one shared resistor on the common pin, which makes brightness vary with the number of lit segments.
- Multiplexing bare digits with delay() in the loop, which makes them flicker.
- Running a 5 V TM1637 module from 3.3 V and getting dim or missing segments; most work at 3.3 V but check yours.
Frequently asked questions
How do I know if a 7-segment display is common anode or common cathode?
Use a multimeter in diode mode between the common pin and a segment pin. If the segment lights with the black lead on the common pin it is common cathode; with the red lead on common it is common anode.
Do I need a resistor for a 7-segment display?
Yes, one per segment (220 to 470 Ω at 5 V) so every segment gets the same current. TM1637 and MAX7219 modules include the current control.
What is the TM1637?
A driver chip that controls up to six 7-segment digits over two wires, with brightness control. It is the easiest way to add a numeric display to an Arduino or ESP32.
Can I use a 7-segment display with an ESP32?
Yes. TM1637 modules work at 3.3 V logic, and MAX7219 modules usually accept 3.3 V data when powered from 5 V.
How many 7-segment displays can one Arduino drive?
With MAX7219 modules, dozens by chaining them on one SPI bus. With TM1637 modules, one per pair of pins.
Parts for this guide
Calculators
Terms in this guide
Projects that use it
Put this into practice: 71 step-by-step builds in our project library use parts from this guide.
Keep learning
Sources
- TM1637 datasheet (Titan Micro)
- MAX7219 datasheet (Analog Devices)
- Kingbright single-digit display datasheets
Written by the Geekobot team from manufacturer datasheets. Always check the datasheet for the exact part and variant you buy.




