程序十一:循环显示m,i,r,t,o,e,k还有笑脸、爱心和四个方向的箭头 (1)Arduino参考开源代码
- /*
- 【Arduino】168种传感器模块系列实验(资料代码+仿真编程+图形编程)
- 程序十一:循环显示m,i,r,t,o,e,k还有笑脸、爱心和四个方向的箭头
- 引脚定义
- DIN = D11
- CLK = D13
- CS = D10
- */
- #include <LedControl.h>//导入驱动库
- int DIN = 11;//定义引脚
- int CS = 10;
- int CLK = 13;
- byte m[8] = {0xE7, 0xFF, 0xFF, 0xDB, 0xDB, 0xDB, 0xC3, 0xC3}; //英文字母m
- byte i[8] = {0x00, 0x10, 0x00, 0x10, 0x10, 0x10, 0x10, 0x10}; //英文字母i
- byte r[8] = {0x00, 0x00, 0x2c, 0x32, 0x20, 0x20, 0x20, 0x20}; //英文字母r
- byte o[8] = {0x00, 0x00, 0x1c, 0x22, 0x22, 0x22, 0x22, 0x1c}; //英文字母o
- byte t[8] = {0x00, 0x00, 0x10, 0x7e, 0x10, 0x10, 0x14, 0x18}; //英文字母t
- byte e[8] = {0x00, 0x3c, 0x42, 0x42, 0x7e, 0x40, 0x40, 0x3e}; //英文字母e
- byte k[8] = {0x00, 0x20, 0x20, 0x24, 0x28, 0x30, 0x28, 0x24}; //英文字母k
- byte smile[8] = {0x3C, 0x42, 0xA5, 0x81, 0xA5, 0x99, 0x42, 0x3C}; //微笑
- byte love_1[8] = {0x00, 0x66, 0x99, 0x81, 0x42, 0x24, 0x18, 0x00}; //爱心-1
- byte love_2[8] = {0x00, 0x66, 0xff, 0xff, 0x7e, 0x3c, 0x18, 0x00}; //爱心-2
- //实心箭头
- byte Front[8] = {0x08, 0x1c, 0x3e, 0x7f, 0x1c, 0x1c, 0x1c, 0x1c}; //前
- byte back[8] = {0x1c, 0x1c, 0x1c, 0x1c, 0x7f, 0x3e, 0x1c, 0x08}; //后
- byte left[8] = {0x10, 0x30, 0x7f, 0xff, 0x7f, 0x30, 0x10, 0x00}; //左
- byte right[8] = {0x08, 0x0c, 0xfe, 0xff, 0xfe, 0x0c, 0x08, 0x00}; //右
- LedControl lc = LedControl(DIN, CLK, CS, 0);//定义引脚
- void setup() {
- lc.shutdown(0, false); //MAX7219启动时处于省电模式
- lc.setIntensity(0, 15); // 将亮度设置为最大值
- lc.clearDisplay(0); // 并清除显示
- }
- void loop() {
- printByte(smile);
- delay(1000);
- printByte(love_1);
- delay(1000);
- printByte(love_2);
- delay(1000);
- printByte(Front);
- delay(1000);
- printByte(back);
- delay(1000);
- printByte(left);
- delay(1000);
- printByte(right);
- delay(1000);
- printLetter();
- lc.clearDisplay(0);
- delay(1000);
- }
- void printLetter(){
- printByte(m);
- delay(1000);
- printByte(i);
- delay(1000);
- printByte(r);
- delay(1000);
- printByte(o);
- delay(1000);
- printByte(t);
- delay(1000);
- printByte(e);
- delay(1000);
- printByte(k);
- delay(1000);
- }
- void printByte(byte character []){
- int i = 0;
- for (i = 0; i < 8; i++)
- {
- lc.setRow(0, i, character[i]);
- }
- }
复制代码
|