MAX7219 7 Segment Arduino: 8-Digit Display with LedControl
MAX7219 7 segment Arduino: SPI wiring, numbers and decimal point with LedControl, brightness, register table, 16 chained digits, clock and temperature code.
The MAX7219 7 segment module is the easiest way to connect an eight-digit numeric display to an Arduino with only three data wires. Normally, driving eight digits of eight segments, 64 LEDs, takes dozens of pins, resistors and code that keeps scanning all the time. The MAX7219 chip takes over all of that: it scans the digits hundreds of times per second on its own, limits the segment current with a single resistor, and you only tell it which digit shows which number. The display keeps glowing without flicker even while the Arduino is busy with other work.
In this guide you'll look inside the MAX7219 and its command (register) table, wire it to an Arduino over SPI, and print integers, negative numbers and decimal points with the LedControl library, plus the 16 brightness levels. Then we'll chain two modules into a 16-digit clock and counter and build a temperature display with a DS18B20. In the last part you'll find an ESP32 NTP clock that uses plain SPI without a library, and a comparison with the popular TM1637 module.

What is the MAX7219 and how does it work?
The MAX7219 is a driver chip made for common-cathode LED displays. Inside it has 8 one-byte memory cells (one per digit), a scan circuit, 16-step brightness control and an optional BCD decoder (Code B). The chip pulls the common pins of the digits to ground one after another and lights the segments of the current digit; it does this at about 800 Hz, so your eye thinks all digits are on at the same time. Because each digit is lit for one eighth of the time, the segments carry a short, high peak current. This peak is set by the RSET resistor on the module; on cheap modules it's usually 10 kΩ, giving about 40 mA peak per segment. Communication with the Arduino uses 16-bit packets: first an 8-bit register address, then 8 bits of data, and the command takes effect when the CS (LOAD) pin goes high.
| Feature | MAX7219 value |
|---|---|
| Supply voltage | 4.0–5.5 V (modules run at 5 V) |
| Interface | 3-wire serial (SPI compatible), up to 10 MHz |
| Capacity | 8 digits × 8 segments = 64 LEDs, common cathode |
| Scan rate | About 800 Hz |
| Brightness | 16 steps (digital PWM) + analog setting via RSET |
| Segment peak current | About 40 mA with RSET = 10 kΩ |
| Shutdown current | About 150 µA |
| Input HIGH threshold | At least 3.5 V (at 5 V supply) |
MAX7219 command (register) table
Even if you use a library, knowing what each command does helps a lot when troubleshooting. Each command is an address plus a value. The digits sit at addresses 0x01–0x08; the rightmost digit of the module is usually 0x01 (digit 0 in LedControl). When decode mode is on for a digit, writing a value from 0 to 9 makes the chip draw the numeral itself; when it's off, each bit lights one segment. In Code B decode mode, besides the numerals 0–9 the chip draws a minus sign for 0x0A, E for 0x0B, H for 0x0C, L for 0x0D and P for 0x0E, while 0x0F leaves the digit blank. In no-decode mode the bit order is D7 = dot, D6 = a, D5 = b, D4 = c, D3 = d, D2 = e, D1 = f, D0 = g. For example the degree sign (a, b, f, g) is 0b01100011 and a capital C (a, d, e, f) is 0b01001110; we'll use them in the temperature code.
| Address | Register | Value and effect | LedControl equivalent |
|---|---|---|---|
| 0x00 | No-Op | Does nothing; used to pass a command through to another module in a chain | Used internally by the library |
| 0x01–0x08 | Digit 0–7 | Segment pattern or Code B numeral of the digit; bit D7 is the decimal point | setDigit(), setChar(), setRow() |
| 0x09 | Decode Mode | 0x00 no decode, 0xFF Code B on all digits | Library uses 0x00 |
| 0x0A | Intensity | 0x00 (dimmest) – 0x0F (brightest) | setIntensity(addr, 0–15) |
| 0x0B | Scan Limit | 0x00–0x07: how many digits are scanned (value + 1) | setScanLimit(addr, 0–7) |
| 0x0C | Shutdown | 0x00 shutdown (display off), 0x01 normal operation | shutdown(addr, true/false) |
| 0x0F | Display Test | 0x01 all LEDs on at full brightness, 0x00 normal | Library sets 0x00 |
Wiring: Arduino Uno and ESP32
| Module pin | Arduino Uno / Nano | ESP32 | Note |
|---|---|---|---|
| VCC | 5V | VIN (5 V) | One module can run from USB |
| GND | GND | GND | Common ground |
| DIN | D11 | GPIO 23 (through a level shifter) | Data in |
| CS / LOAD | D10 | GPIO 5 (through a level shifter) | Command applied on the rising edge |
| CLK | D13 | GPIO 18 (through a level shifter) | Clock |
| DOUT (output side) | Unused | Unused | To the DIN of the next module in a chain |
LedControl sends data in software, so you can actually use any three digital pins. We chose D11, D13 and D10 because they are the Uno's hardware SPI pins: if you later switch to a library that uses hardware SPI, such as MD_MAX72XX, you won't have to rewire. If you're curious about how SPI works, see the what is SPI article, and for a quick look at board pins use the pinout tool.
Step by step: numbers and decimal point with LedControl
- Open the Library Manager in the Arduino IDE, search for LedControl and install the library by Eberhard Fahle.
- Wire the module as in the table: VCC to 5V, GND to GND, DIN to D11, CLK to D13, CS to D10.
- Upload the code below; the display should show 12345678, -2026, 3.14159 and -12.75 in turn.
- In the last step every digit shows "8." and the brightness rises from 0 to 15; pick the level that suits your eyes.
- If the digits come out in reverse order, your module numbers its digits the other way; flip the position in the code to 7 - pos.
1// MAX7219 8 haneli 7 segment: tam sayı, ondalıklı sayı ve parlaklık
2// MAX7219 8-digit 7-segment: integers, decimals and brightness
3#include <LedControl.h>
4
5// LedControl(DIN, CLK, CS, modül sayısı) / LedControl(DIN, CLK, CS, number of modules)
6LedControl lc = LedControl(11, 13, 10, 1);
7
8// Sağa yaslı tam sayı yazar, eksi işaretini destekler (en fazla 8 hane)
9// Prints a right-aligned integer, supports a minus sign (up to 8 digits)
10void printNumber(long n) {
11 lc.clearDisplay(0);
12 bool negative = n < 0;
13 if (negative) n = -n;
14 int pos = 0; // 0 = en sağdaki hane / 0 = rightmost digit
15 do {
16 lc.setDigit(0, pos++, n % 10, false);
17 n /= 10;
18 } while (n > 0 && pos < 8);
19 if (negative && pos < 8) lc.setChar(0, pos, '-', false);
20}
21
22// Ondalıklı sayı: decimals kadar basamak, noktayı ilgili haneye koyar
23// Decimal number: 'decimals' digits after the point, dot lit on the right digit
24void printFloat(float value, int decimals) {
25 long scaled = lround(value * pow(10, decimals));
26 lc.clearDisplay(0);
27 bool negative = scaled < 0;
28 if (negative) scaled = -scaled;
29 int pos = 0;
30 do {
31 lc.setDigit(0, pos, scaled % 10, pos == decimals && decimals > 0); // DP noktası / decimal point
32 scaled /= 10;
33 pos++;
34 } while ((scaled > 0 || pos <= decimals) && pos < 8);
35 if (negative && pos < 8) lc.setChar(0, pos, '-', false);
36}
37
38void setup() {
39 lc.shutdown(0, false); // Uyku modundan çıkar / wake up from shutdown
40 lc.setIntensity(0, 8); // Parlaklık 0-15 / brightness 0-15
41 lc.clearDisplay(0);
42}
43
44void loop() {
45 printNumber(12345678);
46 delay(2000);
47 printNumber(-2026);
48 delay(2000);
49 printFloat(3.14159, 5); // 3.14159
50 delay(2000);
51 printFloat(-12.75, 2); // -12.75
52 delay(2000);
53
54 // Parlaklık taraması: 8 hanenin hepsi "8." / brightness sweep with all digits "8."
55 for (int d = 0; d < 8; d++) lc.setDigit(0, d, 8, true);
56 for (int i = 0; i <= 15; i++) {
57 lc.setIntensity(0, i);
58 delay(150);
59 }
60 lc.setIntensity(0, 8);
61}| Function | What it does | Example |
|---|---|---|
| LedControl(DIN, CLK, CS, n) | Defines the pins and the number of chained modules (1–8) | LedControl(11, 13, 10, 1) |
| shutdown(addr, false) | Wakes the module; it starts in shutdown at power-up | shutdown(0, false) |
| setIntensity(addr, 0–15) | Sets the brightness | setIntensity(0, 8) |
| clearDisplay(addr) | Turns all digits off | clearDisplay(0) |
| setDigit(addr, digit, value, dp) | Writes a value 0–15 (including A–F) to a digit | setDigit(0, 3, 7, true) → "7." |
| setChar(addr, digit, char, dp) | Writes 0–9, A–F, H, L, P, -, _, space | setChar(0, 7, 'H', false) |
| setRow(addr, digit, byte) | Lights segments one by one (custom characters) | setRow(0, 1, 0b01100011) → ° |
The printFloat() function first turns the number into an integer: to print 12.75 with 2 decimals it gets 1275, places the digits from right to left and lights the dot only on the ones digit. This avoids floating-point glitches and also shows the leading zero for values like 0.05. The Arduino float type holds about 7 significant digits, so the last digit can drift on decimals that fill all 8 digits; for measurements, 1–3 decimals are enough anyway.
Brightness and current draw
The intensity register changes the on-time of each digit in 16 steps, from 1/32 to 31/32. The current rises accordingly: on a module with a 10 kΩ RSET, with every segment and dot lit ("8.8.8.8.8.8.8.8."), you can estimate it as 8 segments × 40 mA × duty cycle. Real numbers light about 4–5 segments on average, so the current is roughly half of what the table shows. One module runs easily from USB; for four or more modules use a separate 5 V 2 A supply.
| setIntensity | Duty cycle | Approx. current (all segments) | Use |
|---|---|---|---|
| 0 | 1/32 | 15 mA | Dark room, bedside clock |
| 3 | 7/32 | 80 mA | Desk, indoors |
| 7 | 15/32 | 160 mA | Bright room |
| 11 | 23/32 | 240 mA | Next to a window |
| 15 | 31/32 | 320 mA | Daylight; watch the heat |
Chaining: 16 digits, a clock and a counter with two modules
MAX7219 modules can be chained: the DOUT pin of the first module goes to the DIN of the second, while the CLK and CS lines are shared by all modules. When the Arduino sends a 16-bit command, the previous command sitting in the first module shifts on to the next; when CS goes high, each module applies its own share. LedControl handles this for you and supports up to 8 modules, that is 64 digits. You only set the module count to 2 in the constructor; address 0 is the module wired to the Arduino and address 1 is the one behind it. In the example below the first module shows a clock set from the Serial Monitor as "14-30-05", and the second shows an 8-digit counter that goes up every time you press the button on D2.
1// İki MAX7219 modülü zincirleme (16 hane): üstte saat, altta buton sayacı
2// Two chained MAX7219 modules (16 digits): clock on the first, button counter on the second
3// Saati ayarla / set the clock: Seri Monitör'e / in the Serial Monitor "143005" = 14:30:05
4#include <LedControl.h>
5
6const int BUTTON_PIN = 2; // Sayaç butonu, diğer ucu GND / counter button, other leg to GND
7LedControl lc = LedControl(11, 13, 10, 2); // 2 modül / 2 modules: 0 = Arduino'ya bağlı olan / the one wired to the Arduino
8
9unsigned long clockBase = 0; // Saatin millis() referansı / millis() reference of the clock
10long secondsAtBase = 0; // Ayarlanan saat (saniye) / clock value that was set (seconds)
11long counter = 0;
12bool lastButton = HIGH;
13unsigned long lastPress = 0;
14
15void showClock(long t) {
16 int h = (t / 3600) % 24, m = (t / 60) % 60, s = t % 60;
17 // Hane sırası sağdan sola 0..7: "14-30-05" / digit order right to left 0..7
18 lc.setDigit(0, 7, h / 10, false);
19 lc.setDigit(0, 6, h % 10, false);
20 lc.setChar(0, 5, '-', false);
21 lc.setDigit(0, 4, m / 10, false);
22 lc.setDigit(0, 3, m % 10, false);
23 lc.setChar(0, 2, '-', false);
24 lc.setDigit(0, 1, s / 10, false);
25 lc.setDigit(0, 0, s % 10, false);
26}
27
28void showCounter(long n) {
29 // Baştaki sıfırlar boş kalır / leading zeros stay blank
30 for (int pos = 0; pos < 8; pos++) {
31 if (n == 0 && pos > 0) lc.setChar(1, pos, ' ', false);
32 else lc.setDigit(1, pos, n % 10, false);
33 n /= 10;
34 }
35}
36
37void setup() {
38 Serial.begin(9600);
39 pinMode(BUTTON_PIN, INPUT_PULLUP);
40 for (int dev = 0; dev < lc.getDeviceCount(); dev++) {
41 lc.shutdown(dev, false);
42 lc.setIntensity(dev, 5);
43 lc.clearDisplay(dev);
44 }
45 showCounter(0);
46}
47
48void loop() {
49 // Seri porttan saat ayarı / clock setting from the serial port
50 if (Serial.available()) {
51 char p = Serial.peek();
52 if (p < '0' || p > '9') {
53 Serial.read(); // Satır sonu vb. atla / skip line endings etc.
54 } else {
55 long v = Serial.parseInt(); // örnek / example: 143005
56 if (v < 240000) {
57 secondsAtBase = (v / 10000) * 3600L + ((v / 100) % 100) * 60L + v % 100;
58 clockBase = millis();
59 }
60 }
61 }
62
63 long now = secondsAtBase + (millis() - clockBase) / 1000;
64 static long shown = -1;
65 if (now != shown) { // Saniyede bir güncelle / update once per second
66 shown = now;
67 showClock(now);
68 }
69
70 bool b = digitalRead(BUTTON_PIN);
71 if (b == LOW && lastButton == HIGH && millis() - lastPress > 50) {
72 lastPress = millis();
73 counter = (counter + 1) % 100000000L; // 8 haneye sığar / fits in 8 digits
74 showCounter(counter);
75 }
76 lastButton = b;
77}To set the clock, open the Serial Monitor at 9600 baud and send a six-digit number such as 143005. Because this clock runs on millis(), it depends on the Uno's ceramic resonator and can drift by a few minutes a day. For an accurate clock that survives power cuts, add an RTC clock module, or fetch the time from the internet as in the ESP32 example below. The counter part leaves leading zeros blank, so 42 appears right-aligned as "42" rather than "00000042".
Temperature display: DS18B20 and the degree sign
One of the favourite uses of a 7-segment display is a large temperature readout you can read from across the room. In this example a DS18B20 sensor is connected to D2 with a 4.7 kΩ pull-up resistor between DATA and 5V. The code prints the temperature with its decimal point and draws the degree sign and the letter C on the two right-hand digits with setRow(). The leftmost digit is a threshold indicator: H lights above 30 °C and L below 5 °C. If the sensor is not connected, the display shows "--------". You need to install the OneWire and DallasTemperature libraries from the Library Manager.
1// MAX7219 sıcaklık göstergesi: DS18B20 ile "H 23.5°C" biçimi
2// MAX7219 temperature display: DS18B20 shown as "H 23.5°C"
3#include <LedControl.h>
4#include <OneWire.h>
5#include <DallasTemperature.h>
6
7const int ONE_WIRE_PIN = 2; // DS18B20 DATA (4,7 kΩ pull-up ile 5V'a) / DS18B20 DATA (4.7 kΩ pull-up to 5V)
8const float HIGH_LIMIT = 30.0; // Üstünde "H" yanar / "H" lights above this
9const float LOW_LIMIT = 5.0; // Altında "L" yanar / "L" lights below this
10
11const byte SEG_DEGREE = 0b01100011; // a, b, f, g segmentleri: ° / segments a, b, f, g
12const byte SEG_C = 0b01001110; // a, d, e, f segmentleri: C / segments a, d, e, f
13
14LedControl lc = LedControl(11, 13, 10, 1);
15OneWire oneWire(ONE_WIRE_PIN);
16DallasTemperature sensor(&oneWire);
17
18void showTemperature(float t) {
19 lc.clearDisplay(0);
20 int tenths = (int)lround(t * 10); // 23.46 -> 235
21 bool negative = tenths < 0;
22 if (negative) tenths = -tenths;
23
24 lc.setRow(0, 0, SEG_C); // En sağ hane: C / rightmost digit: C
25 lc.setRow(0, 1, SEG_DEGREE); // Derece işareti / degree sign
26 lc.setDigit(0, 2, tenths % 10, false);
27 lc.setDigit(0, 3, (tenths / 10) % 10, true); // Birler + ondalık nokta / ones + decimal point
28 int pos = 4;
29 int rest = tenths / 100;
30 while (rest > 0 && pos < 7) { // Onlar, yüzler / tens, hundreds
31 lc.setDigit(0, pos++, rest % 10, false);
32 rest /= 10;
33 }
34 if (negative) lc.setChar(0, pos, '-', false);
35
36 if (t > HIGH_LIMIT) lc.setChar(0, 7, 'H', false); // Sıcak uyarısı / too hot
37 else if (t < LOW_LIMIT) lc.setChar(0, 7, 'L', false); // Soğuk uyarısı / too cold
38}
39
40void setup() {
41 lc.shutdown(0, false);
42 lc.setIntensity(0, 6);
43 lc.clearDisplay(0);
44 sensor.begin();
45}
46
47void loop() {
48 sensor.requestTemperatures(); // 12 bit ölçüm yaklaşık 750 ms / 12-bit reading takes about 750 ms
49 float t = sensor.getTempCByIndex(0);
50 if (t == DEVICE_DISCONNECTED_C) {
51 lc.clearDisplay(0);
52 for (int d = 0; d < 8; d++) lc.setChar(0, d, '-', false); // Sensör yok: "--------" / no sensor
53 } else {
54 showTemperature(t);
55 }
56 delay(1000);
57}ESP32 code: an NTP clock with plain SPI
LedControl compiles on the ESP32 too, but this example uses no library so that you can work with the register table directly. The ESP32 uses hardware SPI (VSPI: GPIO 23 MOSI, GPIO 18 SCK) to send an address and a value to each register, switches on Code B decode mode and lets the chip draw the numerals. The time comes from an NTP server over Wi-Fi; the time zone passed to configTzTime() is UTC+3 for Turkey, and a comment shows a German example with daylight saving time. During the last 5 seconds of every half minute the display shows the date as "02.11.26". Enter your Wi-Fi name and password before running the code.
1// ESP32 + MAX7219: kütüphanesiz SPI ve Code B çözme moduyla NTP saati "14-30-05"
2// ESP32 + MAX7219: library-free SPI and Code B decode mode, NTP clock "14-30-05"
3#include <WiFi.h>
4#include <SPI.h>
5#include <time.h>
6
7const char* WIFI_SSID = "WIFI_ADIN"; // Wi-Fi adın / your Wi-Fi name
8const char* WIFI_PASS = "WIFI_SIFREN"; // Wi-Fi şifren / your Wi-Fi password
9const int PIN_CS = 5; // LOAD/CS; DIN = GPIO 23, CLK = GPIO 18 (VSPI)
10
11// MAX7219 yazmaçları / registers
12const byte REG_DECODE = 0x09, REG_INTENSITY = 0x0A, REG_SCANLIMIT = 0x0B,
13 REG_SHUTDOWN = 0x0C, REG_TEST = 0x0F;
14const byte CODE_DASH = 0x0A, CODE_BLANK = 0x0F, DP = 0x80; // Code B: '-' ve boş / '-' and blank
15
16void maxWrite(byte reg, byte value) {
17 SPI.beginTransaction(SPISettings(1000000, MSBFIRST, SPI_MODE0));
18 digitalWrite(PIN_CS, LOW);
19 SPI.transfer(reg); // Önce adres / address first
20 SPI.transfer(value); // Sonra veri / then data
21 digitalWrite(PIN_CS, HIGH); // Yükselen kenarda kilitlenir / latched on the rising edge
22 SPI.endTransaction();
23}
24
25// digit 0 = en sağ hane, yazmaç 0x01 / digit 0 = rightmost, register 0x01
26void setDigit(byte digit, byte code) { maxWrite(digit + 1, code); }
27
28void setup() {
29 pinMode(PIN_CS, OUTPUT);
30 digitalWrite(PIN_CS, HIGH);
31 SPI.begin(18, 19, 23, PIN_CS); // SCK, MISO (kullanılmaz / unused), MOSI, SS
32
33 maxWrite(REG_TEST, 0x00); // Test modu kapalı / display test off
34 maxWrite(REG_SCANLIMIT, 0x07); // 8 hanenin hepsi / all 8 digits
35 maxWrite(REG_DECODE, 0xFF); // 8 hanede Code B çözme / Code B decode on all digits
36 maxWrite(REG_INTENSITY, 0x04); // Parlaklık 4/15 / brightness 4/15
37 maxWrite(REG_SHUTDOWN, 0x01); // Normal çalışma / normal operation
38 for (byte d = 0; d < 8; d++) setDigit(d, CODE_DASH); // Bağlanırken "--------" / "--------" while connecting
39
40 WiFi.begin(WIFI_SSID, WIFI_PASS);
41 while (WiFi.status() != WL_CONNECTED) delay(250);
42 configTzTime("<+03>-3", "pool.ntp.org"); // Türkiye UTC+3; Almanya için / for Germany: "CET-1CEST,M3.5.0,M10.5.0/3"
43}
44
45void loop() {
46 struct tm t;
47 if (!getLocalTime(&t, 1000)) return; // Saat henüz gelmedi / time not received yet
48
49 bool showDate = (t.tm_sec % 30) >= 25; // Her yarım dakikada 5 sn tarih / date for 5 s every half minute
50 if (showDate) {
51 // "02.11.2026" yerine 8 hanede "02.11.26" / "02.11.26" in 8 digits
52 int y = (t.tm_year + 1900) % 100, mo = t.tm_mon + 1;
53 setDigit(7, CODE_BLANK);
54 setDigit(6, t.tm_mday / 10);
55 setDigit(5, (t.tm_mday % 10) | DP);
56 setDigit(4, mo / 10);
57 setDigit(3, (mo % 10) | DP);
58 setDigit(2, y / 10);
59 setDigit(1, y % 10);
60 setDigit(0, CODE_BLANK);
61 } else {
62 setDigit(7, t.tm_hour / 10);
63 setDigit(6, t.tm_hour % 10);
64 setDigit(5, CODE_DASH);
65 setDigit(4, t.tm_min / 10);
66 setDigit(3, t.tm_min % 10);
67 setDigit(2, CODE_DASH);
68 setDigit(1, t.tm_sec / 10);
69 setDigit(0, t.tm_sec % 10);
70 }
71 delay(200);
72}MAX7219 vs TM1637
The other popular 7-segment module is the TM1637. It's usually sold with 4 digits and a colon (for clocks), connects with just two wires and also runs at 3.3 V. Choose using the differences in the table: if you need many digits, chaining and a wider brightness range, go for the MAX7219; for a small clock or timer with few wires and a colon, the TM1637 is more practical.
| Feature | MAX7219 module | TM1637 module |
|---|---|---|
| Digits | 8 (up to 64 when chained) | Usually 4 or 6, cannot be chained |
| Wiring | 3 wires: DIN, CLK, CS (SPI compatible) | 2 wires: CLK, DIO (proprietary, not I2C) |
| Supply and logic | 5 V; needs at least 3.5 V on its inputs | 3.3–5 V; works directly with an ESP32 |
| Brightness | 16 levels | 8 levels |
| Display type | Common cathode | Common anode (on modules) |
| Colon (clock) | None; use a dot or a dash | On the 4-digit module |
| Extras | BCD decoder, also drives 8×8 matrices | Key-scan input |
| Library | LedControl, MD_MAX72XX | TM1637 (TM1637Display) |
Project ideas
- Idea: A visitor counter that counts people coming through a door; start the sensor side with the people counter article.
- Idea: A countdown timer that shows the days, hours, minutes and seconds left until New Year on 8 digits.
- Idea: A real-time desk clock; combine the ESP32 NTP clock logic with the display from this article.
- Idea: A small 16-digit weather station showing temperature on one module and humidity on the other.
- Idea: A bike computer with a magnet and a Hall sensor on the wheel, showing speed and total distance.
- Idea: A reaction test that shows how many milliseconds it takes you to press a button after an LED lights up.
Common problems and fixes
| Symptom | Likely cause | Fix |
|---|---|---|
| Display stays dark | Module still in shutdown, or DIN and DOUT swapped | Call shutdown(0, false) and connect to the input (DIN) side of the module |
| All LEDs at full brightness | Display test mode left on, or CS not connected | Check the CS wire, write 0x00 to register 0x0F |
| Random segments light up | 3.3 V logic or long, noisy wires | Use a level shifter, shorten the wires, add 10 µF + 100 nF across VCC and GND |
| Digits in reverse order | The module numbers its digits differently | Flip the position in the code to 7 - pos |
| Display flickers or dims | Too many modules powered from USB | Use a separate 5 V supply, lower the brightness |
| Second module mirrors the first | Module count left at 1 in the constructor | Write LedControl(11, 13, 10, 2) and use address 1 |
| Decimal point on the wrong digit | The dot was set on the next digit | Set dp to true in the setDigit() call of the ones digit |
The MAX7219 8-digit 7-segment module is one of the cheapest ways to show large, readable numbers with a few lines of code; clocks, counters, thermometers and scoreboards all use the same three basic functions. If you want to go step by step from 7-segment basics to applications such as a four-digit clock or a bomb countdown animation, the BlueGrays app has 7-segment projects with circuit diagrams and ready-to-use code.
Frequently asked questions
How do I connect a MAX7219 7-segment display to Arduino?
Connect the module's VCC to 5V, GND to GND, and DIN, CLK and CS to three digital pins; on the Uno D11, D13 and D10 are a common choice. In the LedControl library you pass these pins to the constructor and wake the module with shutdown(0, false) in setup(). No extra resistors are needed because the RSET resistor on the module limits the segment current.
How do I light the decimal point with LedControl?
The last parameter of setDigit() and setChar() is the dot; pass true and the dot to the right of that digit lights up. For example setDigit(0, 3, 7, true) shows "7." on the fourth digit. For decimal numbers the dot belongs on the ones digit, and the printFloat() function in this article does that automatically.
How many MAX7219 modules can be daisy-chained?
There's no hard limit in hardware because each module passes the data on to the next, but LedControl supports up to 8 modules, or 64 digits. As you add modules, updates get a little slower and the current goes up. With four or more modules you should use a separate 5 V supply.
Does the MAX7219 work with an ESP32?
Yes, but the MAX7219 needs at least 3.5 V on its inputs for a HIGH and the ESP32 outputs 3.3 V. Many modules work anyway, but for reliable results you should put a logic level converter on the DIN, CLK and CS lines. Power the module from the ESP32's VIN (5 V) pin, not from 3V3.
Which is better, MAX7219 or TM1637?
It depends on what you need. The MAX7219 offers 8 digits, 16 brightness levels and chaining, so it's ideal for long numbers and multi-digit displays. The TM1637 connects with two wires, runs at 3.3 V and has a colon for clocks, which makes it more practical for small clock and timer projects.
Can a MAX7219 display show letters?
Partly. LedControl's setChar() writes 0–9, A–F, H, L, P, minus, underscore and space; you can draw other letters by lighting segments one by one with setRow(). Letters such as K, M, W and X don't come out readable on 7 segments. For text-heavy projects an 8×8 LED matrix is a better choice.
Projects to build after reading this
See all projects
Displaying Numbers 0-9 on a 7-Segment Display
Write those familiar numbers you see in elevators and digital clocks yourself. On a display made of seven little light bars, the Arduino shows a digit from 0 to 9, one each second, and then starts…

Displaying 0-9999 on a 4-Digit 7-Segment Display
On a four-digit number display, numbers race from 0 to 9999 and then start again from zero.

Digital Clock with 4-Digit 7-Segment Display
A four-digit glowing digital clock, much like the one on a kitchen oven. The DS1302 clock module keeps the time, and every second the Arduino reads the hours and minutes and shows them on the…

Counter with 7-Segment Display and Buttons
A simple counter with three buttons: press one and the digit on the display goes up by one, press another and it goes down by one, and the third sends it back to zero.

Bomb Animation with 4-Digit 7-Segment Display
The ticking bomb scene from the films, right on your desk and completely harmless: the 4-digit display counts down from 1:05, the buzzer beeps every second and the red LED blinks.

ESP32 TM1637 4-Digit 7-Segment Display
We are controlling a 4-digit 7-segment display module with a TM1637 driver using an ESP32. Using just 2 GPIO pins (CLK and DIO), we run a counter from 0 to 9999, adjust the brightness level, and display the colon (:) character in clock format. Thanks to the TM1637Display library, controlling numbers, hex values, segments, and strings is very easy.

Dot Matrix Clock and Calendar (MAX7219, DS1307)
A glowing board for your desk or wall that shows the time and date in scrolling text.

Real-Time Clock from the Internet via ESP32 NTP
The ESP32 connects to Wi-Fi and fetches the real time from NTP (Network Time Protocol) servers with millisecond precision. configTzTime() applies the Turkey time zone (TRT, UTC+3) automatically, and in countries with daylight saving time the DST switch is handled by a POSIX TZ string. The time is printed both to the Serial Monitor and to an optional I2C LCD.
More articles
BlueGrays app
Build this circuit step by step on your phone
Wiring diagram, code and parts list on one screen. 500+ Arduino, ESP32, ESP8266, Pico, mBot and micro:bit projects ready to build.
Scan with your phone
Point your camera at the code and your phone's app store opens.
or open the store

