Components · 9 min read

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.

Four-digit common-cathode 7-segment display
An 8-digit MAX7219 module carries two four-digit displays like this side by side; the MAX7219 drives common-cathode displays.

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.

FeatureMAX7219 value
Supply voltage4.0–5.5 V (modules run at 5 V)
Interface3-wire serial (SPI compatible), up to 10 MHz
Capacity8 digits × 8 segments = 64 LEDs, common cathode
Scan rateAbout 800 Hz
Brightness16 steps (digital PWM) + analog setting via RSET
Segment peak currentAbout 40 mA with RSET = 10 kΩ
Shutdown currentAbout 150 µA
Input HIGH thresholdAt 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.

AddressRegisterValue and effectLedControl equivalent
0x00No-OpDoes nothing; used to pass a command through to another module in a chainUsed internally by the library
0x01–0x08Digit 0–7Segment pattern or Code B numeral of the digit; bit D7 is the decimal pointsetDigit(), setChar(), setRow()
0x09Decode Mode0x00 no decode, 0xFF Code B on all digitsLibrary uses 0x00
0x0AIntensity0x00 (dimmest) – 0x0F (brightest)setIntensity(addr, 0–15)
0x0BScan Limit0x00–0x07: how many digits are scanned (value + 1)setScanLimit(addr, 0–7)
0x0CShutdown0x00 shutdown (display off), 0x01 normal operationshutdown(addr, true/false)
0x0FDisplay Test0x01 all LEDs on at full brightness, 0x00 normalLibrary sets 0x00

Wiring: Arduino Uno and ESP32

Module pinArduino Uno / NanoESP32Note
VCC5VVIN (5 V)One module can run from USB
GNDGNDGNDCommon ground
DIND11GPIO 23 (through a level shifter)Data in
CS / LOADD10GPIO 5 (through a level shifter)Command applied on the rising edge
CLKD13GPIO 18 (through a level shifter)Clock
DOUT (output side)UnusedUnusedTo 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.

The MAX7219 runs at 5 V and needs at least 3.5 V on its inputs to see a HIGH. The ESP32 and the Raspberry Pi Pico output 3.3 V, which is below that limit; many modules still work, but some show random characters or don't react at all. For reliable results put a logic level converter (for example a 74HCT125 or a BSS138 module) on the DIN, CLK and CS lines. Never power the module from the ESP32's 3V3 pin.

Step by step: numbers and decimal point with LedControl

  1. Open the Library Manager in the Arduino IDE, search for LedControl and install the library by Eberhard Fahle.
  2. Wire the module as in the table: VCC to 5V, GND to GND, DIN to D11, CLK to D13, CS to D10.
  3. Upload the code below; the display should show 12345678, -2026, 3.14159 and -12.75 in turn.
  4. In the last step every digit shows "8." and the brightness rises from 0 to 15; pick the level that suits your eyes.
  5. 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.
C++ (Arduino IDE)
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}
FunctionWhat it doesExample
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-upshutdown(0, false)
setIntensity(addr, 0–15)Sets the brightnesssetIntensity(0, 8)
clearDisplay(addr)Turns all digits offclearDisplay(0)
setDigit(addr, digit, value, dp)Writes a value 0–15 (including A–F) to a digitsetDigit(0, 3, 7, true) → "7."
setChar(addr, digit, char, dp)Writes 0–9, A–F, H, L, P, -, _, spacesetChar(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.

setIntensityDuty cycleApprox. current (all segments)Use
01/3215 mADark room, bedside clock
37/3280 mADesk, indoors
715/32160 mABright room
1123/32240 mANext to a window
1531/32320 mADaylight; 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.

C++ (Arduino IDE)
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.

C++ (Arduino IDE)
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.

C++ (Arduino IDE)
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.

FeatureMAX7219 moduleTM1637 module
Digits8 (up to 64 when chained)Usually 4 or 6, cannot be chained
Wiring3 wires: DIN, CLK, CS (SPI compatible)2 wires: CLK, DIO (proprietary, not I2C)
Supply and logic5 V; needs at least 3.5 V on its inputs3.3–5 V; works directly with an ESP32
Brightness16 levels8 levels
Display typeCommon cathodeCommon anode (on modules)
Colon (clock)None; use a dot or a dashOn the 4-digit module
ExtrasBCD decoder, also drives 8×8 matricesKey-scan input
LibraryLedControl, MD_MAX72XXTM1637 (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

SymptomLikely causeFix
Display stays darkModule still in shutdown, or DIN and DOUT swappedCall shutdown(0, false) and connect to the input (DIN) side of the module
All LEDs at full brightnessDisplay test mode left on, or CS not connectedCheck the CS wire, write 0x00 to register 0x0F
Random segments light up3.3 V logic or long, noisy wiresUse a level shifter, shorten the wires, add 10 µF + 100 nF across VCC and GND
Digits in reverse orderThe module numbers its digits differentlyFlip the position in the code to 7 - pos
Display flickers or dimsToo many modules powered from USBUse a separate 5 V supply, lower the brightness
Second module mirrors the firstModule count left at 1 in the constructorWrite LedControl(11, 13, 10, 2) and use address 1
Decimal point on the wrong digitThe dot was set on the next digitSet dp to true in the setDigit() call of the ones digit
Only update the display when the value changes. If a temperature or counter is rewritten on every loop, all digits go dark for a moment between clearDisplay() and the new write, which shows up as visible flicker. As in the clock example, keep the last value shown in a variable and send it only when it differs; at night, lowering the brightness to 0–2 is easier on both your eyes and the current draw.

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.

See all projects
Displaying Numbers 0-9 on a 7-Segment Display
AR-41Intermediate
Premium

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…

4.5(30)
43
Displaying 0-9999 on a 4-Digit 7-Segment Display
AR-47Intermediate
Premium

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.

4.4(19)
25
Digital Clock with 4-Digit 7-Segment Display
AR-48Intermediate
Premium

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…

4.8(56)
73
Counter with 7-Segment Display and Buttons
AR-43Advanced
Premium

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.

4.6(35)
47
Bomb Animation with 4-Digit 7-Segment Display
AR-49Beginner
Premium

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.

4.8(63)
79
ESP32 TM1637 4-Digit 7-Segment Display
ES-23Intermediate
Premium

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.

4.7(20)
32
Dot Matrix Clock and Calendar (MAX7219, DS1307)
AR-84Intermediate
Premium

Dot Matrix Clock and Calendar (MAX7219, DS1307)

A glowing board for your desk or wall that shows the time and date in scrolling text.

5.0(37)
59
Real-Time Clock from the Internet via ESP32 NTP
ES-26Advanced
Premium

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.

4.5(13)
22