[code]#include <LedControl.h>
int DIN = 2;
int CS = 3;
int CLK = 4;
byte e[8] = {0x7C, 0x7C, 0x60, 0x7C, 0x7C, 0x60, 0x7C, 0x7C}; //E
byte d[8] = {0x78, 0x7C, 0x66, 0x66, 0x66, 0x66, 0x7C, 0x78}; //D
byte u[8] = {0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x7E, 0x7E}; //U
byte c[8] = {0x7E, 0x7E, 0x60, 0x60, 0x60, 0x60, 0x7E, 0x7E}; //C
byte eight[8] = {0x7E, 0x7E, 0x66, 0x7E, 0x7E, 0x66, 0x7E, 0x7E}; //8
byte s[8] = {0x7E, 0x7C, 0x60, 0x7C, 0x3E, 0x06, 0x3E, 0x7E}; //S
byte dot[8] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x18}; //.
byte o[8] = {0x7E, 0x7E, 0x66, 0x66, 0x66, 0x66, 0x7E, 0x7E}; //O
byte m[8] = {0xE7, 0xFF, 0xFF, 0xDB, 0xDB, 0xDB, 0xC3, 0xC3}; //M
byte smile[8] = {0x3C, 0x42, 0xA5, 0x81, 0xA5, 0x99, 0x42, 0x3C}; //笑臉
byte neutral[8] = {0x3C, 0x42, 0xA5, 0x81, 0xBD, 0x81, 0x42, 0x3C}; //標(biāo)準(zhǔn)臉
LedControl lc = LedControl(DIN, CLK, CS, 4);
void setup() {
for(int index=0;index<lc.getDeviceCount();index++) {
lc.shutdown(index, false); //啟動時,MAX72XX處于省電模式
lc.setIntensity(index, 4); //將亮度設(shè)置為最大值
lc.clearDisplay(index); //清除顯示
}
}
void loop() {
printByte(smile);//顯示
delay(1000);//延時1秒
printByte(neutral);//顯示標(biāo)準(zhǔn)臉
delay(1000);
}
//點(diǎn)陣顯示函數(shù)
void printByte(byte character [])
{
int i = 0;
for (i = 0; i < 8; i++)
{
lc.setRow(0, i, character[i]);
lc.setRow(1, i, character[i]);
lc.setRow(2, i, character[i]);
lc.setRow(3, i, character[i]);
}
}
|