8x8 LED matrix/How it lights/04. Eight bytes for sixty-four LEDs
How it lights · 04 of 10

Eight bytes for sixty-four LEDs

The whole picture is eight bytes, one per column. On the TK52, register 1 is the left-hand column and bit 0 of each register is the top LED. Pick an LED and the figure shows which bit of which register lights it.

One bit per LED

Eight bytes for sixty-four LEDs
Start from
This LED
column 1, row 1
Is
register 1, bit 0
Lit
1 of 64
The LED in column 1, row 1 is bit 0 of register 1, and it is on. One register per column, one bit per LED: the whole picture is these eight bytes. This is the TK52 held matrix up, header down, worked out from the matrix's datasheet and the board's copper; if your picture comes out turned, the sketch's TURN setting fixes it.

Each of the chip's eight digit registers holds one column. A 1 bit lights an LED; a 0 leaves it dark. Eight registers of eight bits is sixty-four LEDs, and nothing else is needed to describe a picture.

Which bit is which LED depends on how the matrix is wired to the chip, and the chip cannot know. On the TK52, held matrix up and header down:

RegisterColumnBit 0Bit 7
1lefttop LEDbottom LED
8righttop LEDbottom LED

That comes from the board's net list and the 1088AS datasheet: the chip's digit 0 is wired to the matrix's row 1 and its DP segment, bit 7, to column 1, and the matrix sits on the board turned a quarter from the datasheet's drawing. It is worked out rather than photographed from a lit board, so the book's sketch carries a TURN and a FLIP setting in case your board disagrees.

Rows in, columns out

People draw pictures in rows, top first. The sketch's HEART is written that way, eight lines of 1s and 0s you can read as the picture. Its show() function turns the rows into the eight column bytes the chip wants, one register at a time. So you never write a column byte yourself.

The old sketch on this page reversed every byte "to fix a mirror" and wrote each one as a row. By the wiring above, on this board that gives the picture reflected across its diagonal rather than upright.

When it does not work

My picture is on its side.

The bytes went in as rows rather than columns. The book's sketch takes a picture drawn as rows, top first, and turns it into columns for you. If it still comes out turned, set TURN to 1, 2 or 3 in the sketch.

My picture is mirrored.

Either the bits are in the wrong order or the columns are. Set FLIP to true in the book's sketch. LedControl's setRow writes a byte straight into a register, so on this board it writes a column, bottom LED in the top bit.

Some LEDs show segments of a digit instead of my pattern.

The decode-mode register is on. Write 0 to register 0x09 so every bit is one LED. With decoding on, the chip reads the low four bits as a number and draws its seven-segment shape.

How do I draw my own picture?

Draw it on eight lines of eight 1s and 0s, top row first, 1 for lit, and put them in the sketch the way HEART is. The sketch does the turning into columns.

Alongside this page
Where this goes next

Sixteen levels, each a longer share of every column's turn.

Brightness is time, not current →

Edit this page — content/books/matrix-led/eight-bytes-for-sixty-four-leds.mdx

Community

Questions about this product

See what other owners have asked, and read their solutions.

This page covers several products. Choose yours to see the right discussions.

Discuss this article

Ask about this page. The answer stays here, on the page it belongs to, for whoever hits the same wall next.

Browse Modules and blocks on the forum →