寫程式46.jpg

💽影片名稱:[Arduino寫程式] 第46集 - LED 8x8矩陣 模組

🎬集數:46集🎤背景音樂:Spring In My Step🎤背景音樂:Sugar Zone🎤背景音樂:Walk With Me🎤背景音樂:Weekend Fun🎤背景音樂:Corporate Technology [Presentation Music]💕若有問題歡迎在下方留言💬讓我知道~😋


🌐(前往YouTube觀看)-[ https://youtu.be/kazN66SqLhA?feature=shared ]

🌐(YouTube播放清單)-[ https://youtube.com/playlist?list=PLOrdAySpFIQonYKEWANFiVrICDQY8R0_1&feature=shared ]


🌐程式創造++ 頻道:[ https://www.youtube.com/@CCplus2561 ]🌐Arduino程式語法網頁:[ https://www.86duino.com/?page_id=2255&lang=TW ]


[腳位圖]

[IN位子] VCC = 5V GND = GND DIN = 7 CS = 6 CLK = 5

 

[OUT位子]可串聯矩陣2(IN)相同腳位.進行擴大圖形

寫程式46 - LED 8x8矩陣 模組 腳位圖.png

▲ 腳位圖@CCplus2561 提供

 

寫程式46 - LED 8x8矩陣 模組 素材.png

@CCplus2561 提供


[程式碼]

EX01: 範例程式圖

#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); 


EX02: 顯示箭頭移動圖案

#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,   //圖形1
      0x08387fffff781808,   //圖形2
      0x1070fefefef03010,   //圖形3
      0x20e0fcfcfce06020,
      0x40c0f8f8f8c0c040,
      0x8080f0f0f0808080,
      0x0000e0e0e0000000,
      0x0000c0c0c0000000,
      0x0000808080000000,
      0x0000000000000000
};

const int IMAGES_LEN = sizeof(IMAGES)/8;  //總共有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.15秒
}


EX03: 顯示ALO破解者圖案

#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秒
}

創作者介紹
創作者 Code Create++ 的頭像
程式創造++

Code Create++

程式創造++ 發表在 痞客邦 留言(0) 人氣( 0 )