/*
  矩陣圖案生成網站:https://xantorohara.github.io/led-matrix-editor/#
  教學範例:https://atceiling.blogspot.com/2020/11/arduino948x8-led.html
*/


#include <LedControl.h>
// Pin 12:Data in, Pin 11: Clock,  Pin 10: CS(Load)
LedControl display = LedControl(12, 11, 10, 1);

const uint64_t R_IMAGES[] = {   //往右箭頭
  0x0000000080000000,
  0x0000000080000000,
  0x00000080c0800000,
  0x000080c0e0c08000,
  0x0080c0e0f0e0c080,
  0x004060f0f8f06040,
  0x002030f8fcf83020,
  0x001018fcfefc1810,
  0x001018fcfefc1810,
  0x00080cfefffe0c08,
  0x0004067f7f7f0604,
  0x0002033f3f3f0302,
  0x0001011f1f1f0101,
  0x0000000f0f0f0000,
  0x0000000707070000,
  0x0000000303030000,
  0x0000000101010000,
  0x0000000000000000
};
const int R_IMAGES_LEN = sizeof(R_IMAGES) / 8;


void setup()
{
  display.clearDisplay(0);    // 清除螢幕
  display.shutdown(0, false);  // 關閉省電模式
  display.setIntensity(0, 15); // 設定亮度為 8 (介於0~15之間)

}
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(R_IMAGES[i]);
  if (++i >= R_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