硬件准备:HW-277 Arduino UNO控制板*1
HW-109 8*8点阵模块*1
USB线*1
杜邦线*5
接线图:
接线对照:
HW-277开发板 HW-109点阵模块
5V-------------------------------------------------------------------------------VCC
GND-----------------------------------------------------------------------------GND
D11(MOSI)----------------------------------------------------------------------DIN
D10(SS)--------------------------------------------------------------------------CS
D13(SCK)-------------------------------------------------------------------------CLK
程序代码:
const byte sprite[5][8] = {
{ 0x00, 0x66, 0xFF, 0xFF, 0xFF, 0x7E, 0x3C, 0x18 },
{ 0x00, 0x00, 0x24, 0x7E, 0x7E, 0x3C, 0x18, 0x00 },
{ 0x10, 0x10, 0x7C, 0x54, 0x54, 0x7C, 0x10, 0x10 },
{ 0xFF, 0xBD, 0x89, 0xBD, 0x8B, 0xBD, 0x81, 0xFF },
{ 0x66, 0xFF, 0x99, 0x81, 0xC3, 0x66, 0x3C, 0x18 }
};
const byte DECODEMODE = 0x09;
const byte INTENSITY = 0x0a;
const byte SCANLIMIT = 0x0b;
const byte SHUTDOWN = 0x0c;
const byte DISPLAYTEST = 0x0f;
void max7219(const byte reg, const byte data) {
digitalWrite(SS, LOW);
SPI.transfer(reg);
SPI.transfer(data);
digitalWrite(SS, HIGH);
}
void setup() {
SPI.begin();
max7219(SCANLIMIT, 7);
max7219(DECODEMODE, 0);
max7219(INTENSITY, 2);
max7219(DISPLAYTEST, 0);
max7219(SHUTDOWN, 1);
for(byte i=0; i<8; i++) {
max7219(i+1, 0);
}
}
void loop() {
for(byte j=0; j<5; j++) {
for(byte i=0; i<8; i++) {
max7219(i+1, sprite[j][i]);
}
delay(500);
}
}
效果图:
深圳市宏维微电子有限公司:20190924