The MAX7219 is a chip that drives up to 8 seven-segment digits over a simple 3-wire SPI interface. You get a whole module pre-assembled — the chip, the display, decoupling caps, all on one board. It's one of the easier displays to get working with Arduino because the library handles all the multiplexing.
The module has 10 pins total, five on each side. One side is the input, the other is output for daisy-chaining multiple modules together. You only need the input side: VCC, GND, DIN, LOAD, and CLK.
Parts
- Arduino (Uno, Nano, or similar)
- MAX7219 8-digit 7-segment display module
- Jumper wires
Wiring
Connect the input side of the module to the Arduino as follows:
- VCC → 5V
- GND → GND
- DIN → pin 12
- CLK → pin 11
- LOAD → pin 10
Wiring is straightforward. The module runs on 5V and the SPI lines go directly to the Arduino digital pins.
Library
Install the LedControl library from the Arduino Library Manager. Search for "LedControl" and install the one by Eberhard Fahle. No other dependencies needed.
Sketch
Initialize a LedControl object with the three pin numbers and the number of daisy-chained modules. Then wake it up, set the brightness (0–15), and clear the display. To show a digit, use setDigit — pass the device index, the position counting from right starting at zero, the digit value, and whether to show the decimal point. To show letters, use setChar instead. Not all characters are possible on a 7-segment display, but H, E, L, P, and a few others work fine.
#include "LedControl.h"
LedControl lc = LedControl(12, 11, 10, 1);
unsigned long delaytime = 500;
void setup() {
lc.shutdown(0, false);
lc.setIntensity(0, 8);
lc.clearDisplay(0);
}
void goofy() {
lc.setChar(0, 7, 'H', false);
lc.setChar(0, 6, 'E', false);
lc.setChar(0, 5, 'L', false);
lc.setChar(0, 4, 'P', false);
lc.setChar(0, 3, '.', false);
lc.setChar(0, 2, '.', false);
lc.setChar(0, 1, '.', false);
lc.setChar(0, 0, '.', false);
delay(delaytime + 1000);
lc.clearDisplay(0);
delay(delaytime * 3);
}
void loop() {
goofy();
}
Chaining modules
The DOUT side is for chaining. Connect DOUT of the first module to DIN of the second, increase the device count in the LedControl constructor, and address each module by its index. You can chain several modules off the same three Arduino pins.
Result
Upload the sketch and you should see it working immediately. The digits light up, the decimal point is controllable per digit, and brightness is easy to adjust in code. Full sketch is on my GitHub and linked from my site. If you build something with it — a clock, a counter, whatever — share it in the Discord.