I’ve been playing with the LedControl library again, this time preparing my 8×8 matrices to be used as a clock, although I’m waiting for two more to arrive from AliExpress.

Anyway, its pretty simple to wire them up in series, you basically use the same pinout for connecting to an Arduino as you do for connecting the matrices together – VCC, GND, DIN, CS, CLK.

For my sketch, I’d prefer them to be rotated 90 degrees, so that the input/chip was on the bottom and output wires at the top (rather than left to right), so I had to edit the hex a bit.

At the moment I’m just using an Arduino Nano3 clone as it has a handy 5v output, eventually I’ll convert it to using a NodeMCU (or bare ESP-14) or a Raspberry Pi Zero, as I want wifi support for fetching time via NTP, however LedControl seems to be AVR-specific as it uses PROGMEM etc; I had some success with this library on my NodeMCU, scrolling wasn’t great though.

The sketch basically counts from 01-12, the same as the hours on a clock, I’ve just got to add the minutes, but that will be simple enough.

#include "LedControl.h"

// data-in, clock, cs, numdevices
LedControl lc = LedControl(12,11,10,2);

const int num[10][8] = {
    {0x00,0x78,0xcc,0xec,0xfc,0xdc,0xcc,0x78}, // zero
    {0x00,0xfc,0x30,0x30,0x30,0x30,0xf0,0x30}, // one
    {0x00,0xfc,0xcc,0x60,0x38,0x0c,0xcc,0x78}, // two
    {0x00,0x78,0xcc,0x0c,0x38,0x0c,0xcc,0x78}, // three
    {0x00,0x0c,0x0c,0xfe,0xcc,0x6c,0x3c,0x1c}, // four
    {0x00,0x78,0xcc,0x0c,0x0c,0xf8,0xc0,0xfc}, // five
    {0x00,0x78,0xcc,0xcc,0xf8,0xc0,0x60,0x38}, // six
    {0x00,0x60,0x60,0x30,0x18,0x0c,0xcc,0xfc}, // seven
    {0x00,0x78,0xcc,0xcc,0x78,0xcc,0xcc,0x78}, // eight
    {0x00,0x70,0x18,0x0c,0x7c,0xcc,0xcc,0x78}  // nine
};

/* non-rotated version
int num[10][8] = {
    {0x7c,0xfe,0x9a,0xb2,0xfe,0x7c,0x00,0x00}, // zero
    {0x42,0x42,0xfe,0xfe,0x02,0x02,0x00,0x00}, // one
    {0x46,0xce,0x9a,0x92,0xf6,0x66,0x00,0x00}, // two
    {0x44,0xc6,0x92,0x92,0xfe,0x6c,0x00,0x00}, // three
    {0x18,0x38,0x68,0xc8,0xfe,0xfe,0x08,0x00}, // four
    {0xe4,0xe6,0xa2,0xa2,0xbe,0x9c,0x00,0x00}, // five
    {0x3c,0x7e,0xd2,0x92,0x9e,0x0c,0x00,0x00}, // six
    {0xc0,0xc6,0x8e,0x98,0xf0,0xe0,0x00,0x00}, // seven
    {0x6c,0xfe,0x92,0x92,0xfe,0x6c,0x00,0x00}, // eight
    {0x60,0xf2,0x92,0x96,0xfc,0x78,0x00,0x00}  // nine
};
*/

void drawNum(int number, int display)
{
    lc.setColumn(display, 0, num[number][0]);
    lc.setColumn(display, 1, num[number][1]);
    lc.setColumn(display, 2, num[number][2]);
    lc.setColumn(display, 3, num[number][3]);
    lc.setColumn(display, 4, num[number][4]);
    lc.setColumn(display, 5, num[number][5]);
    lc.setColumn(display, 6, num[number][6]);
    lc.setColumn(display, 7, num[number][7]);
}

void setup(void)
{
    // switch from powersaving into normal mode
    lc.shutdown(0,false);
    lc.shutdown(1,false);

    // set the brightness 0..15
    lc.setIntensity(0,8);
    lc.setIntensity(1,8);
}

void loop()
{
    // 0
    lc.clearDisplay(1);
    drawNum(0,0);

    // 1-9
    for (int i=1; i<=9; i++)
    {
        lc.clearDisplay(1);
        drawNum(i,1);
        delay(1000);
    }

    // 10
    lc.clearDisplay(0);
    drawNum(1,0);
    lc.clearDisplay(1);
    drawNum(0,1);
    delay(1000);

    // 11
    lc.clearDisplay(1);
    drawNum(1,1);
    delay(1000);

    // 12
    lc.clearDisplay(1);
    drawNum(2,1);
    delay(1000);
}

And the Makefile:

BOARD_TAG    = nano328
MONITOR_PORT = /dev/ttyUSB0
ARDUINO_LIBS = LedControl

include /usr/share/arduino/Arduino.mk