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
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:
| Register | Column | Bit 0 | Bit 7 |
|---|---|---|---|
| 1 | left | top LED | bottom LED |
| 8 | right | top LED | bottom 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
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.
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.
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.
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.
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
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.