|

楼主 |
发表于 2021-9-11 12:45
|
显示全部楼层
【Arduino】168种传感器模块系列实验(资料代码+仿真编程+图形编程)
实验二十二:MAX7219点阵显示模块(8X8 LED共阴)
项目二十九:满屏矩阵变换
实验开源代码
- /*
- 【Arduino】168种传感器模块系列实验(资料代码+仿真编程+图形编程)
- 实验二十二:MAX7219点阵显示模块(8X8 LED共阴)
- 项目二十九:满屏矩阵变换
- 接脚连线:
- MAX7219 UNO
- VCC →→→→→ 5V
- GND →→→→→ GND
- DIN →→→→→ D12(数据,数据接收引脚)
- CS →→→→→ D11(负载,命令接收引脚)
- CLK →→→→→ D10(时钟,时钟引脚)
- */
- #include <LedControl.h>
- int DIN = 12;
- int CS = 11;
- int CLK = 10;
- //Main
- byte Design1[8] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,};
- byte Design2[8] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,};
- byte Design3[8] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x03,};
- byte Design4[8] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x03, 0x07,};
- byte Design5[8] = {0x00, 0x00, 0x00, 0x00, 0x01, 0x03, 0x07, 0x0F,};
- byte Design6[8] = {0x00, 0x00, 0x00, 0x01, 0x03, 0x07, 0x0F, 0x1F,};
- byte Design7[8] = {0x00, 0x00, 0x01, 0x03, 0x07, 0x0F, 0x1F, 0x3F,};
- byte Design8[8] = {0x00, 0x01, 0x03, 0x07, 0x0F, 0x1F, 0x3F, 0x7F,};
- byte Design9[8] = {0x01, 0x03, 0x07, 0x0F, 0x1F, 0x3F, 0x7F, 0xFF,};
- byte Design10[8] = {0x03, 0x07, 0x0F, 0x1F, 0x3F, 0x7F, 0xFF, 0xFF,};
- byte Design11[8] = {0x07, 0x0F, 0x1F, 0x3F, 0x7F, 0xFF, 0xFF, 0xFF,};
- byte Design12[8] = {0x0F, 0x1F, 0x3F, 0x7F, 0xFF, 0xFF, 0xFF, 0xFF,};
- byte Design13[8] = {0x1F, 0x3F, 0x7F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,};
- byte Design14[8] = {0x3F, 0x7F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,};
- byte Design15[8] = {0x7F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,};
- byte Design16[8] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,};
- byte Design17[8] = {0xBF, 0x7F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,};
- byte Design18[8] = {0xAF, 0x5F, 0xBF, 0x7F, 0xFF, 0xFF, 0xFF, 0xFF,};
- byte Design19[8] = {0xAB, 0x57, 0xAF, 0x5F, 0xBF, 0x7F, 0xFF, 0xFF,};
- byte Design20[8] = {0xAA, 0x55, 0xAB, 0x57, 0xAF, 0x5F, 0xBF, 0x7F,};
- byte Design21[8] = {0xAA, 0x55, 0xAA, 0x55, 0xAB, 0x57, 0xAF, 0x5F,};
- byte Design22[8] = {0xAA, 0x55, 0xAA, 0x55, 0xAA, 0x55, 0xAB, 0x57,};
- byte Design23[8] = {0xAA, 0x55, 0xAA, 0x55, 0xAA, 0x55, 0xAA, 0x55,};
- //Blink
- byte BlinkOn1[8] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,};
- byte BlinkOff1[8] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,};
- byte BlinkOn2[8] = {0xAA, 0x55, 0xAA, 0x55, 0xAA, 0x55, 0xAA, 0x55,};
- byte BlinkOff2[8] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,};
- LedControl lc = LedControl(DIN, CLK, CS, 0);
- void setup() {
- lc.shutdown(0, false); //The MAX72XX is in power-saving mode on startup
- lc.setIntensity(0, 10); // Set the brightness to maximum value
- lc.clearDisplay(0); // and clear the display
- }
- void loop() {
- printByte(Design1);
- delay(100);
- printByte(Design2);
- delay(100);
- printByte(Design3);
- delay(100);
- printByte(Design4);
- delay(100);
- printByte(Design5);
- delay(100);
- printByte(Design6);
- delay(100);
- printByte(Design7);
- delay(100);
- printByte(Design8);
- delay(100);
- printByte(Design9);
- delay(100);
- printByte(Design10);
- delay(100);
- printByte(Design11);
- delay(100);
- printByte(Design12);
- delay(100);
- printByte(Design13);
- delay(100);
- printByte(Design14);
- delay(100);
- printByte(Design15);
- delay(100);
- printByte(Design16);
- delay(100);
- //Blink1
- printByte(BlinkOn1);
- delay(350);
- printByte(BlinkOff1);
- delay(350);
- printByte(BlinkOn1);
- delay(350);
- printByte(BlinkOff1);
- delay(350);
- printByte(BlinkOn1);
- delay(350);
- //Design2
- printByte(Design17);
- delay(100);
- printByte(Design18);
- delay(100);
- printByte(Design19);
- delay(100);
- printByte(Design20);
- delay(100);
- printByte(Design21);
- delay(100);
- printByte(Design22);
- delay(100);
- printByte(Design23);
- delay(100);
- //Blink2
- printByte(BlinkOn2);
- delay(350);
- printByte(BlinkOff2);
- delay(350);
- printByte(BlinkOn2);
- delay(350);
- printByte(BlinkOff2);
- delay(350);
- }
- void printByte(byte character []){
- int i = 0;
- for (i = 0; i < 8; i++){
- lc.setRow(0, i, character[i]);
- }
- }
复制代码
|
|