#include <LedControl.h> //MAX7219ENG IC 函式庫
const int DIN_PIN = 7; //DIN腳位
const int CS_PIN = 6; //CS腳位
const int CLK_PIN = 5; //CLK腳位
const uint64_t IMAGES[] = {
0x0000000000000000,
0x0101010101000000,
0x0303030303010000,
0x0607070606030100,
0x0c0f0f0c0c060301,
0x181f1f18180c0703,
0x303f3f3030190f06,
0x617f7f6161331e0c,
0xc3ffffc3c3663c18,
0x86fefe8686cc7830,
0x86fefe8686cc7830,
0x0cfcfc0c0c98f060,
0x18f8f8181830e0c0,
0x30f0f0303060c080,
0x60e0e06060c08000,
0xc0c0c0c0c0800000,
0x8080808080000000,
0x0000000000000000,
0x0101000000000000,
0x0303000000000000,
0x0707000000000000,
0x0f0f000000000000,
0x1f1f000000000000,
0x3f3f000000000000,
0x7f7f010101010101,
0xffff030303030303,
0xfefe060606060606,
0xfcfc0c0c0c0c0c0c,
0xf8f8181818181818,
0xf0f0303030303030,
0xe0e0606060606060,
0xc0c0c0c0c0c0c0c0,
0x8080808080808080,
0x0000000000000000,
0x0000000000000000,
0x0000010101010000,
0x0001030303030100,
0x0103060606060301,
0x03070c0c0c0c0703,
0x070f181818180f07,
0x0f1f303030301f0f,
0x1e3f616161613f1e,
0x3c7ec3c3c3c37e3c,
0x78fc86868686fc78,
0xf0f80c0c0c0cf8f0,
0xe0f018181818f0e0,
0xc0e030303030e0c0,
0x80c060606060c080,
0x0080c0c0c0c08000,
0x0000808080800000,
0x0000000000000000,
0x0000000000000000,
0x0001000001000100,
0x0003000103000300,
0x0006010207010701,
0x000d02050f020f02,
0x001b050b1f051f04,
0x00370b173f0a3f08,
0x006f162e7f157f10,
0x00df2d5dff2aff20,
0x00be5abafe54fe40,
0x007cb474fca8fc80,
0x00f868e8f850f800,
0x00f0d0d0f0a0f000,
0x00e0a0a0e040e000,
0x00c04040c080c000,
0x0080808080008000,
0x0000000000000000,
0x0000000000000000,
0x0001000100010101,
0x0103010301020203,
0x0207020702040507,
0x040e050f05090a0f,
0x091d0b1f0b12141e,
0x123b163e1725293c,
0x24772c7c2f4a5379,
0x49ef59f95f94a7f2,
0x92deb2f2be284ee4,
0x24bc64e47c509cc8,
0x4878c8c8f8a03890,
0x90f09090f0407020,
0x20e02020e080e040,
0x40c04040c000c080,
0x8080808080008000,
0x0000000000000000,
0x0000000000000000,
0x0101010001000000,
0x0302030003000100,
0x0704070007000300,
0x0f090f010f010701,
0x1e121e031f020f02,
0x3c243d063f041f04,
0x78497a0c7f083e08,
0xf092f418fe107c10,
0xe024e830fc20f820,
0xc048d060f840f040,
0x8090a0c0f080e080,
0x00204080e000c000,
0x00408000c0008000,
0x0080000080000000,
0x0000000000000000
};
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++) { //8個訊號
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(150); //延遲0.3秒
}
請先 登入 以發表留言。