#include <LedControl.h>
// Vcc 接 5V , GND接GND,DIN接到5號腳位,CS接到6號腳位 ,CLK接到7號腳位
LedControl lc = LedControl(5, 7, 6, 1);
// 大心形
byte heart_big[8] = {
0b01100110,
0b11111111,
0b11111111,
0b11111111,
0b01111110,
0b00111100,
0b00011000,
0b00000000
};
// 小心形
byte heart_small[8] = {
0b00000000,
0b01100110,
0b01111110,
0b00111100,
0b00011000,
0b00000000,
0b00000000,
0b00000000
};
void setup() {
lc.shutdown(0, false); // 啟動顯示
lc.setIntensity(0, 8); // 設定亮度(0到15)
lc.clearDisplay(0); // 清除顯示
}
void loop() {
// 顯示大心形
for (int row = 0; row < 8; row++) {
lc.setRow(0, row, heart_big[row]);
}
delay(400); // 心臟收縮時間
// 顯示小心形
for (int row = 0; row < 8; row++) {
lc.setRow(0, row, heart_small[row]);
}
delay(300); // 心臟舒張時間
}
留言
張貼留言