Board and part

Arduino Uno MAX7219 Simulator: Wiring, Code and a Live Circuit

This is an 8x8 LED matrix on a MAX7219 driver wired to an Arduino Uno, showing a heart live in your browser with the LedControl library and pulsing its brightness.

  • 5 V logic
  • Library: LedControl.h
  • DIN 8, CLK 10, CS 9
  • 8x8, intensity 0 to 15
Arduino Uno · MAX7219live0.000 s 0.00x
Click to open it in the editor
The circuit itself, running on the simulator with the sketch below. Press what can be pressed; click anything else to open it in the editor.
Connections

Wiring the MAX7219 to the Arduino Uno

Five wires: 5 V, ground, and DIN, CLK and CS to pin 8, pin 10 and pin 9.

Every connection in the circuit above, with the board’s own pin names.

MAX7219 pinArduino Uno pinWhy
VCC5VThe MAX7219 runs from 4 to 5.5 V; the module is a 5 V part.
GNDGNDCommon ground.
DINpin 8Data into the chip, clocked in one bit at a time.
CSpin 9Chip select, also called LOAD: it latches the bits into the display.
CLKpin 10The clock that moves each bit of DIN in.

Power

The module takes 5 V from the Arduino Uno’s 5V pin and its inputs read the board’s 5 V signals directly. A full 8x8 matrix at maximum brightness draws a few hundred milliamps, so keep the intensity low or give it its own 5 V supply.

Pins to leave alone on the Arduino Uno

Pins 0 and 1 are the USB serial port on a real Uno, so anything wired there fights the upload and the serial monitor. Pin 13 carries the onboard LED.

On a real bench

On a real bench the Uno stands beside the breadboard: the MAX7219 goes into the breadboard and male-to-male jumpers run from the Uno’s female headers to its rows. Power the Uno from USB while you build, and unplug it before you move a wire.

The sketch

The code, and what it does.

The sketch the circuit above runs. Open it in the editor, change a line and press Run: it compiles in your browser.

MAX7219 matrix on Arduino Uno pin 8, pin 10, pin 9
#include <LedControl.h>

const int DIN_PIN = 8;   // pin 8
const int CLK_PIN = 10;   // pin 10
const int CS_PIN = 9;    // pin 9

LedControl lc = LedControl(DIN_PIN, CLK_PIN, CS_PIN, 1);   // one 8x8 block

// A heart, one byte per row, top row first.
const byte HEART[8] = {
  B00000000, B01100110, B11111111, B11111111,
  B11111111, B01111110, B00111100, B00011000,
};

void setup() {
  Serial.begin(9600);
  lc.shutdown(0, false);     // wake the chip up
  lc.setIntensity(0, 4);     // 0 to 15
  lc.clearDisplay(0);
  for (int row = 0; row < 8; row++) {
    lc.setRow(0, row, HEART[row]);
  }
  Serial.println("Matrix ready");
}

void loop() {
  lc.setIntensity(0, 2);
  delay(500);
  lc.setIntensity(0, 12);
  delay(500);
}

LedControl lc(DIN, CLK, CS, 1) bit-bangs the chip’s three-wire interface on any three pins and says there is one 8x8 block. shutdown(0, false) wakes the chip, which powers up asleep, and clearDisplay() blanks it.

setRow() writes one row of eight LEDs as a byte, so the HEART table is the picture, one byte per row, top row first. The chip keeps the picture and refreshes it itself, so the sketch only has to write it once.

setIntensity() takes 0 to 15, and the loop moves it between 2 and 12 so you can see the brightness change.

Pitfalls

Common mistakes with the MAX7219 on the Arduino Uno

Forgetting to wake the chip

The MAX7219 starts in shutdown mode with the display off. Without lc.shutdown(0, false) every row you write goes in and nothing lights.

Mixing up DIN and DOUT

DIN is the input end of the module. DOUT is the output to the next block in a chain. Wired to DOUT, the board talks to nothing.

Running the matrix at full brightness from USB

Sixty-four LEDs at intensity 15 draw several hundred milliamps. Keep the intensity low in code, or power the module from its own 5 V supply and join the grounds.

FAQ

Questions and answers

How do I connect a MAX7219 matrix to an Arduino Uno?

Power it from 5V and GND, and wire DIN, CLK and CS to pin 8, pin 10 and pin 9. Then create an LedControl with those pins in that order, DIN first.

Which library should I use?

LedControl is the simplest and is what this page uses. MD_MAX72XX adds scrolling text and several block types, and wires the same way.

Why is the picture mirrored or turned?

Modules are wired differently. Reverse the bits of each row to mirror it, or write the rows in reverse order to flip it.

Can I chain more than one block?

Yes. Join each module’s DOUT to the next one’s DIN, share CLK and CS, and give LedControl the number of blocks. In the editor, set the part’s count property.

Build your own MAX7219 project

Open this circuit in the editor, change the wiring or the code, and keep your version in a free account.