Source: https://mokxi.com/libraries/ledcontrol
Updated: 2026-11-02

Libraries / Displays
Arduino library · Displays

# LedControl: MAX7219 matrices and digit displays

LedControl, by Eberhard Fahle, drives the MAX7219: the chip on the red 8x8 dot matrix modules and the eight-digit seven-segment boards. One MAX7219 handles 64 LEDs, and up to eight of them can be chained, each passing data on to the next, all from three Arduino pins: DIN (data), CLK and CS (also marked LOAD).

Open the example in the editor See the calls

Built in on Mokxi: #include <LedControl.h> and it builds, with nothing to install. Free, and no account needed.

## What LedControl does

Every call takes the device number first, 0 for the module nearest the board. The library talks to the chip over software SPI, so the three pins can be any digital pins, and it starts every chip in power-saving shutdown. Nothing lights until the sketch wakes each one with shutdown(addr, false), which is the single most common reason a first LedControl sketch shows nothing.

On a matrix, setRow() takes a byte where each bit is one LED, which makes drawing small pictures easy: write the picture as eight binary numbers. The four-in-one FC-16 boards are wired rotated, so on those a row in the code can come out as a column on the module.

Library Manager name | LedControl

Author | Eberhard Fahle

Include | #include <LedControl.h>

Boards | every board Mokxi compiles for but ATtiny85

In the simulator | Simulated: it runs against the part the way it does on the bench.

Parts it drives | LED matrix, 8x8, Eight-digit display, MAX7219

## Install it

It builds on every board Mokxi compiles for but ATtiny85.

In Mokxi it is built in: #include <LedControl.h> and the sketch compiles, with no download, no zip and no Library Manager.

On a real board, install "LedControl" by Eberhard Fahle from the Arduino IDE’s Library Manager (Sketch, Include Library, Manage Libraries), or add LedControl to lib_deps in PlatformIO. Mokxi follows the calls of release 1.0.6, so a sketch written here builds there too.

ESP32-C3 · Arduino Uno · Arduino Nano · Arduino Mega 2560 · Arduino Leonardo · SparkFun Pro Micro · Arduino Micro · ESP32-C6 · Raspberry Pi Pico · Raspberry Pi Pico W · Seeed XIAO SAMD21 · STM32 · STM32 Nucleo-F411RE · STM32 Blue Pill · micro:bit V2 · Arduino Uno R4 · ESP32 DevKit · ESP32-S3-DevKitC-1 · ESP8266 NodeMCU · Arduino Pro Mini 3.3 V · Seeed XIAO ESP32-C3 · ESP32-C3 SuperMini · Seeed XIAO ESP32-C6 · ESP32-DevKitC V4 · LOLIN32 Lite · Wemos D1 R32 · Cheap Yellow Display · TTGO T-Display · Seeed XIAO ESP32-S3 · Arduino Nano ESP32 · Arduino Nano RP2040 Connect · Seeed XIAO RP2040 · Waveshare RP2040-Zero · Arduino Uno R4 WiFi

## The calls you will use

In the order a sketch meets them.

### LedControl lc = LedControl(12, 11, 10, 1)

DIN, CLK and CS pins, and how many chips are chained (1 to 8).

### lc.shutdown(0, false)

Wakes device 0 from the power-saving mode it starts in. Call it for every device in the chain in setup().

### lc.setIntensity(0, 8)

Brightness of one device, from 0 to 15.

### lc.clearDisplay(0)

Turns every LED of one device off.

### lc.setRow(0, row, 0b00111100)

Sets the eight LEDs of a row from one byte, a bit per LED. setColumn() does the same for a column.

### lc.setLed(0, row, col, true)

Turns a single LED on or off, for a moving dot or a snake game.

### lc.setDigit(0, 3, 7, false)

On a seven-segment board, shows digit 7 in position 3; the last argument lights the decimal point. setChar() shows the few letters the chip knows.

## Example: Light-up Valentine heart

On the Arduino Uno R3. It runs in the browser exactly as printed.

sketch.ino · Arduino Uno R3

Open it in the editor, wired and ready to run · Light-up Valentine heart: the project page

## Common errors and how to fix them

### The module stays dark after upload

The MAX7219 starts in shutdown. Call lc.shutdown(0, false) in setup() for each device, then set an intensity; without it the chip receives data but never lights.

### Only the first module of a chain shows anything

The last constructor argument is the number of devices and defaults to 1. Pass the real count, and address the others as 1, 2 and so on.

### Pictures come out rotated or mirrored on a 4-in-1 board

FC-16 style modules wire the matrix turned 90 degrees. Draw with setColumn() in place of setRow(), flip the bit order, or use the MD_MAX72XX library, which knows that hardware type.

## Projects that use LedControl

Built-in projects that include it. Each page has the full sketch and opens in the editor, already wired.

MAX7219 8x8 matrix (pins 12, 10 and 11) An 8x8 LED matrix on a MAX7219 module with DIN on pin 12, CLK on 10 and CS on 11: LedControl draws a smile, a frown and a heart in turn. Tilt dice on an 8x8 matrix Shake the tilt switch on pin 2 and an 8x8 MAX7219 matrix (DIN 13, CLK 7, CS 8) rolls a die and settles on a number, while an RGB LED on pins 9, 6 and 5 shows when it has stopped. Tilt maze Tilt an ADXL335 and a dot rolls around an 8x8 LED matrix, through a little maze to the blinking goal, then the maze changes. Scoreboard A MAX7219 eight-digit display driven with LedControl: home score, a ten-minute game clock and the guest score, with a button for each team and one for the clock. Hatching chick An egg on an 8x8 MAX7219 matrix wobbles, cracks three times and hatches into a chick that blinks and peeps on a piezo. Catch the beans: a tilt game on an 8x8 matrix Tip an MPU-6050 to slide a cup along a MAX7219 matrix (DIN 13, CLK 7, CS 8) and catch the falling beans.

## Keep going

### Learn

- Arduino MAX7219 8x8 LED Matrix: Wiring and Code
- Arduino Snake Game on an 8x8 LED Matrix (MAX7219)

### Parts

- LED matrix, 8x8
- Eight-digit display, MAX7219

### More displays libraries

- Adafruit SSD1306
- Adafruit GFX Library
- LiquidCrystal I2C
- LiquidCrystal
- LCD_I2C
- hd44780
- TFT_eSPI
- U8g2

Every built-in library · Open the editor

## Try LedControl without installing anything

Open the example, change the sketch, and keep your version in a free account.

Start building free

Open the editor
