MAX7219 8x8 matrix (pins 12, 10 and 11), on an Arduino Uno
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. The whole build, an Arduino Uno and 1 more part, runs here in your browser on the firmware below; open it in the editor to change the wiring or the code and run it again.
Teaching? Assign it to your class in one click.
Beginner Runs in your browser. Free, and no account needed.
The code
The firmware exactly as the editor opens it. Change a line there and press Run: it compiles in the browser.
// An 8x8 LED matrix on a MAX7219: three faces, one after another.
//
// MAX7219 DIN -> pin 12 CLK -> pin 10 CS -> pin 11
// MAX7219 VCC -> 5V GND -> GND
//
// Sixty-four LEDs would need sixty-four pins driven directly. The MAX7219
// scans the rows itself; the Uno only sends it one byte per row over three
// wires. LedControl does the sending. Its constructor takes DIN, CLK, CS and
// the number of modules chained together.
//
// Each picture is eight bytes, one per row, with the leftmost LED in the top
// bit. Draw your own on squared paper and type it in.
#include <LedControl.h>
LedControl lc = LedControl(12, 10, 11, 1);
const byte SMILE[8] = {0x3C, 0x42, 0xA5, 0x81, 0xA5, 0x99, 0x42, 0x3C};
const byte FROWN[8] = {0x3C, 0x42, 0xA5, 0x81, 0x99, 0xA5, 0x42, 0x3C};
const byte HEART[8] = {0x00, 0x66, 0xFF, 0xFF, 0xFF, 0x7E, 0x3C, 0x18};
void draw(const byte *picture, const char *name) {
for (int row = 0; row < 8; row++) lc.setRow(0, row, picture[row]);
Serial.println(name);
}
void setup() {
lc.shutdown(0, false); // the module starts asleep
lc.setIntensity(0, 8); // 0 to 15
lc.clearDisplay(0);
Serial.begin(9600);
Serial.println("Mokxi Uno: MAX7219 on pins 12 (DIN), 10 (CLK) and 11 (CS)");
}
void loop() {
draw(SMILE, "smile");
delay(1000);
draw(FROWN, "frown");
delay(1000);
draw(HEART, "heart");
delay(1000);
}
Parts list
3 parts, plus the jumper wires. Every one is in the editor's parts bin.
- 1 × Arduino Uno R3
- 1 × Half breadboard
- 1 × LED matrix, 8x8
How it is wired
5 connections, pin by pin, read from the circuit itself. Each line is one set of pins joined together, by a jumper wire or a breadboard strip.
- Ground: Arduino Uno R3 pin GND; LED matrix, 8x8 pin GND
- Arduino Uno R3 pin 12; LED matrix, 8x8 pin DIN
- Arduino Uno R3 pin 11; LED matrix, 8x8 pin CS
- Arduino Uno R3 pin 10; LED matrix, 8x8 pin CLK
- Arduino Uno R3 pin 5V; LED matrix, 8x8 pin VCC
Change it and keep it
Open it in the editor, change the circuit or the code, and keep your version in a free account.