MAX7219 LED matrix driver

The MAX7219, wired to 8x8 LED matrix modules the cheap boards use: three wires in, and a chainable output.

The chip holds eight 8-bit digit registers and scans them itself. On a matrix module, DIG0–DIG7 are the eight rows and the segment lines are the eight columns, so the eight digit registers are the picture, one byte per row: write a row register, the row changes.

Pins

Pin What it does
VCC Supply.
GND Ground.
DIN Serial data in, shifted on every rising CLK edge, whatever CS is doing.
CS Latches the last 16 bits shifted in as one register write, on its rising edge.
CLK The shift clock.
DOUT The far end of the internal 16-bit register, for chaining.

Properties

count: how many devices are chained inside this one part, modeling a multi-block module. 1 by default.

What the model gets right

A packet is CS low, 16 clocks, CS high; the 16 bits are four don't-care bits, a 4-bit register address, and an 8-bit data byte, MSB first. Decode mode is modeled because it is really in the chip, not because a matrix needs it. With the bit set, a digit register's low nibble is looked up in the Code B font and the resulting segment pattern is what lights. On power-up every register clears (shutdown, no decode, intensity 0, scan limit 0), which is why a real board (and this one) shows nothing at all until the sketch writes Shutdown, Scan Limit and Intensity.

What it does not model

The multiplex is not there. A real MAX7219 lights one digit at a time and walks through them at about 800 Hz, so each row is on for an eighth of the time and the whole picture is an illusion your eye assembles, which is why a photograph of one shows a single bright row, and why the scan limit changes how bright the display looks. Here every enabled row is shown at once. Scan limit decides which rows are dark and nothing else.

Intensity is the chip's own 16 levels handed to the canvas as a brightness, not a current: the RSET resistor that actually sets the segment current is not a pin here, there is no per-row or per-segment current, no supply draw and no LED aging. No timing is modeled on the serial port either: CLK has no maximum rate, CS has no setup or hold requirement, and DOUT follows DIN with no delay.

Common mistakes

Forgetting to write Shutdown, Scan Limit and Intensity after power-up. A chip left at its power-on defaults shows a blank panel, which is exactly what the datasheet says and exactly what beginners read as a broken part.

See it in action

Matrix ball, Snake on two matrices and Stacker all chain MAX7219 modules together. Open them at /templates.