閃爍十字架

 #include <LedControl.h>


// LED Matrix 腳位設定

#define DATA_IN 5   // DIN

#define CLK_PIN 7   // CLK

#define LOAD_PIN 6  // CS


LedControl lc = LedControl(DATA_IN, CLK_PIN, LOAD_PIN, 1);


// 十字架圖案 1(粗)

byte cross1[8] = {

  B00011000,

  B00011000,

  B01111110,

  B01111110,

  B00011000,

  B00011000,

  B00011000,

  B00011000

};


// 十字架圖案 2(細)

byte cross2[8] = {

   B00000000,

   B00000000,

   B00000000,

   B00000000,

   B00000000,

   B00000000,

   B00000000,

   B00000000

};


void setup() {

  lc.shutdown(0, false);     // 啟動 LED 模組

  lc.setIntensity(0, 5);     // 設定亮度(0~15)

  lc.clearDisplay(0);        // 清除顯示

}


void loop() {

  displayPattern(cross1);

  delay(700);

  displayPattern(cross2);

  delay(300);

}


// 顯示圖案函數

void displayPattern(byte pattern[8]) {

  for (int row = 0; row < 8; row++) {

    lc.setRow(0, row, pattern[row]);

  }

}


留言