Board and part

Raspberry Pi Pico MAX7219 Simulator: Wiring, Code and a Live Circuit

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

  • 3.3 V logic
  • Library: LedControl.h
  • DIN 10, CLK 12, CS 11
  • 8x8, intensity 0 to 15
Raspberry Pi Pico · 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 Raspberry Pi Pico

Five wires: 5 V, ground, and DIN, CLK and CS to GP10 (physical pin 14), GP12 (physical pin 16) and GP11 (physical pin 15).

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

MAX7219 pinRaspberry Pi Pico pinWhy
VCCVBUS (5 V from USB)The MAX7219 runs from 4 to 5.5 V; the module is a 5 V part.
GNDGNDCommon ground.
DINGP10 (physical pin 14)Data into the chip, clocked in one bit at a time.
CSGP11 (physical pin 15)Chip select, also called LOAD: it latches the bits into the display.
CLKGP12 (physical pin 16)The clock that moves each bit of DIN in.

Power

The MAX7219 is a 5 V chip and reads a high as about 3.5 V at that supply, so the Raspberry Pi Pico’s 3.3 V signals are right at its edge. Many modules still work from 3.3 V logic, and a 74AHCT125 on DIN, CLK and CS makes it certain. The matrix at full brightness draws a few hundred milliamps, more than a USB pin should be asked for: keep the intensity down or use its own 5 V supply.

Pins to leave alone on the Raspberry Pi Pico

The numbers in the code are GP numbers, not the physical pin numbers printed beside the header: GP15 is pin 20. GP23 to GP25 are used on the board itself, and GP25 is the LED.

On a real bench

Solder headers on the Pico and press it into the breadboard across the center channel; the MAX7219 goes in beside it. GND pins sit every fifth pin down both sides (pins 3, 8, 13, 18 and so on), so there is always one close. The first upload needs BOOTSEL held while plugging in.

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 Raspberry Pi Pico GP10 (physical pin 14), GP12 (physical pin 16), GP11 (physical pin 15)
#include <LedControl.h>

const int DIN_PIN = 10;   // GP10 (physical pin 14)
const int CLK_PIN = 12;   // GP12 (physical pin 16)
const int CS_PIN = 11;    // GP11 (physical pin 15)

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(115200);
  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 Raspberry Pi Pico

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 a Raspberry Pi Pico?

Power it from VBUS (5 V from USB) and GND, and wire DIN, CLK and CS to GP10 (physical pin 14), GP12 (physical pin 16) and GP11 (physical pin 15). 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.