/*
Matrix as a 64-bit long integer
State of the 8x8 matrix can be presented as an unsigned long integer (uint64_t).
In this case the code is pretty compact. Like this code for Arduino:
翻譯:
64 位長整數矩陣
8x8 矩陣的狀態可以表示為無符號長整數 (uint64_t)。
在這種情況下,程式碼非常緊湊。 就像 Arduino 的程式碼一樣:
網址:https://xantorohara.github.io/led-matrix-editor/#
*/
#include <LedControl.h>
const int DIN_PIN = 7;
const int CS_PIN = 6;
const int CLK_PIN = 5;
const uint64_t IMAGES[] = {
0xff000001010000ff, 0xff000003030000ff, 0xff000006060000ff,
0xff00000c0c0000ff, 0xff000018180000ff, 0xff000030300000ff,
0xff000060600000ff, 0xff0000c0c00000ff, 0xff000080800000ff,
0xff0000c0c00000ff, 0xff000060600000ff, 0xff000018180000ff,
0xff00000c0c0000ff, 0xff000006060000ff, 0xff000003030000ff,
0xff000001010000ff
};
const int IMAGES_LEN = sizeof(IMAGES) / 8;
LedControl display = LedControl(DIN_PIN, CLK_PIN, CS_PIN);
void setup() {
display.clearDisplay(0);
display.shutdown(0, false);
display.setIntensity(0, 10);
}
void displayImage(uint64_t image) {
for (int i = 0; i < 8; i++) {
byte row = (image >> i * 8) & 0xFF;
for (int j = 0; j < 8; j++) {
display.setLed(0, i, j, bitRead(row, j));
}
}
}
int i = 0;
void loop() {
displayImage(IMAGES[i]);
if (++i >= IMAGES_LEN ) {
i = 0;
}
delay(100);
}
nano:12
nano:11
nano:10
nano:9
nano:8
nano:7
nano:6
nano:5
nano:4
nano:3
nano:2
nano:GND.2
nano:RESET.2
nano:0
nano:1
nano:13
nano:3.3V
nano:AREF
nano:A0
nano:A1
nano:A2
nano:A3
nano:A4
nano:A5
nano:A6
nano:A7
nano:5V
nano:RESET
nano:GND.1
nano:VIN
nano:12.2
nano:5V.2
nano:13.2
nano:11.2
nano:RESET.3
nano:GND.3
matrix1:V+
matrix1:GND
matrix1:DIN
matrix1:CS
matrix1:CLK
matrix1:V+.2
matrix1:GND.2
matrix1:DOUT
matrix1:CS.2
matrix1:CLK.2