Arduino爱好者

 找回密码
 立即注册

QQ登录

只需一步,快速开始

楼主: eagler8

[经验] 【Arduino】108种传感器系列实验(22)---MAX7219点阵模块

[复制链接]
 楼主| 发表于 2022-4-29 18:11 | 显示全部楼层
2)实验场景图

11.1-38.jpg

 楼主| 发表于 2022-4-29 18:11 | 显示全部楼层

程序九:依序点亮每一颗LED 再依序熄灭每一颗LED
1Arduino参考开源代码


  1. /*
  2.   【Arduino】168种传感器模块系列实验(资料代码+仿真编程+图形编程)
  3.   程序九://依序点亮每一颗LED 再依序熄灭每一颗LED
  4.   引脚定义
  5.   DIN = D11
  6.   CS  = D10
  7.   CLK = D13
  8. */

  9. //依序亮每一颗LED 再依序灭每一颗LED
  10. #include "LedControl.h"  //引用 LedControl 库
  11. LedControl lc = LedControl(11, 13, 10, 1); //定义DIN,CLK,CS

  12. void setup() {
  13.   lc.shutdown(0, false); // 关闭省电模式
  14.   lc.setIntensity(0, 0); // 设定亮度为 0 (介于0~15之间)
  15.   lc.clearDisplay(0);    // 清除屏幕
  16. }

  17. void loop() {
  18.   int col;
  19.   int row;
  20.   for (col = 0; col < 8; col++) {
  21.     for (row = 0; row < 8; row++) {
  22.       lc.setLed(0, row, col, 1); // 将Led的列,行设定为亮
  23.       delay(100);
  24.     }
  25.   }
  26.   for (col = 7; col >= 0; col--) {
  27.     for (row = 7; row >= 0; row--) {
  28.       lc.setLed(0, row, col, 0); // 将Led的列,行设定为暗
  29.       delay(100);
  30.     }
  31.   }
  32. }
复制代码


 楼主| 发表于 2022-4-29 18:12 | 显示全部楼层
2)实验场景图

11.1-39.jpg

 楼主| 发表于 2022-4-29 18:13 | 显示全部楼层
程序十:依序显示 A,r,d,u,i,n,o
1Arduino参考开源代码

  1. /*
  2.   【Arduino】168种传感器模块系列实验(资料代码+仿真编程+图形编程)
  3.   程序十:依序显示 A,r,d,u,i,n,o
  4.   引脚定义
  5.   DIN = D11
  6.   CLK = D13
  7.   CS  = D10
  8. */

  9. #include "LedControl.h"  //引用 LedControl 库

  10. LedControl lc = LedControl(11, 13, 10, 1); //定义DIN,CLK,CS

  11. //字型码A,r,d,u,i,n,o
  12. byte a[5]={B01111110,B10001000,B10001000,B10001000,B01111110};
  13. byte r[5]={B00111110,B00010000,B00100000,B00100000,B00010000};
  14. byte d[5]={B00011100,B00100010,B00100010,B00010010,B11111110};
  15. byte u[5]={B00111100,B00000010,B00000010,B00000100,B00111110};
  16. byte i[5]={B00000000,B00100010,B10111110,B00000010,B00000000};
  17. byte n[5]={B00111110,B00010000,B00100000,B00100000,B00011110};
  18. byte o[5]={B00011100,B00100010,B00100010,B00100010,B00011100};


  19. void setup() {
  20.   lc.shutdown(0, false); // 关闭省电模式
  21.   lc.setIntensity(0, 15); // 设定亮度为 0 (介于0~15之间)
  22.   lc.clearDisplay(0);    // 清除屏幕
  23. }

  24. void loop() {

  25.   //显示 A
  26.   for(int j=0;j<5;j++){
  27.     //显示 0~4 行
  28.     lc.setColumn(0,j,a[j]);
  29.   }
  30.   delay(500);      

  31.   //显示 r
  32.   for(int j=0;j<5;j++){
  33.     //显示 0~4 行
  34.     lc.setColumn(0,j,r[j]);
  35.   }   
  36.   delay(500);      

  37.   //显示 d
  38.   for(int j=0;j<5;j++){
  39.     //显示 0~4 行
  40.     lc.setColumn(0,j,d[j]);
  41.   }   
  42.   delay(500);      

  43.   //显示 u
  44.   for(int j=0;j<5;j++){
  45.     //显示 0~4 行
  46.     lc.setColumn(0,j,u[j]);
  47.   }   
  48.   delay(500);      

  49.   //显示 i
  50.   for(int j=0;j<5;j++){
  51.     //显示 0~4 行
  52.     lc.setColumn(0,j,i[j]);
  53.   }   
  54.   delay(500);      

  55.   //显示 n
  56.   for(int j=0;j<5;j++){
  57.     //显示 0~4 行
  58.     lc.setColumn(0,j,n[j]);
  59.   }   
  60.   delay(500);      

  61.   //显示 o
  62.   for(int j=0;j<5;j++){
  63.     //显示 0~4 行
  64.     lc.setColumn(0,j,o[j]);
  65.   }   
  66.   delay(50);      
  67. }
复制代码


 楼主| 发表于 2022-4-29 18:14 | 显示全部楼层
2)实验场景图

11.1-40.jpg

11.1-41.jpg

 楼主| 发表于 2022-4-29 18:33 | 显示全部楼层
11.1-42.jpg

11.1-43.jpg
 楼主| 发表于 2022-4-29 18:52 | 显示全部楼层
11.1-44.jpg

11.1-45.jpg
 楼主| 发表于 2022-4-29 18:53 | 显示全部楼层
11.1-46.jpg
 楼主| 发表于 2022-4-29 18:53 | 显示全部楼层
程序十一:循环显示m,i,r,t,o,e,k还有笑脸、爱心和四个方向的箭头
1Arduino参考开源代码

  1. /*
  2.   【Arduino】168种传感器模块系列实验(资料代码+仿真编程+图形编程)
  3.   程序十一:循环显示m,i,r,t,o,e,k还有笑脸、爱心和四个方向的箭头
  4.   引脚定义
  5.   DIN = D11
  6.   CLK = D13
  7.   CS  = D10
  8. */

  9. #include <LedControl.h>//导入驱动库

  10. int DIN = 11;//定义引脚
  11. int CS =  10;
  12. int CLK = 13;

  13. byte m[8] =     {0xE7, 0xFF, 0xFF, 0xDB, 0xDB, 0xDB, 0xC3, 0xC3}; //英文字母m
  14. byte i[8] =     {0x00, 0x10, 0x00, 0x10, 0x10, 0x10, 0x10, 0x10}; //英文字母i
  15. byte r[8] =     {0x00, 0x00, 0x2c, 0x32, 0x20, 0x20, 0x20, 0x20}; //英文字母r
  16. byte o[8] =     {0x00, 0x00, 0x1c, 0x22, 0x22, 0x22, 0x22, 0x1c}; //英文字母o
  17. byte t[8] =     {0x00, 0x00, 0x10, 0x7e, 0x10, 0x10, 0x14, 0x18}; //英文字母t
  18. byte e[8] =     {0x00, 0x3c, 0x42, 0x42, 0x7e, 0x40, 0x40, 0x3e}; //英文字母e
  19. byte k[8] =     {0x00, 0x20, 0x20, 0x24, 0x28, 0x30, 0x28, 0x24}; //英文字母k

  20. byte smile[8] =   {0x3C, 0x42, 0xA5, 0x81, 0xA5, 0x99, 0x42, 0x3C}; //微笑
  21. byte love_1[8] =   {0x00, 0x66, 0x99, 0x81, 0x42, 0x24, 0x18, 0x00}; //爱心-1
  22. byte love_2[8] =   {0x00, 0x66, 0xff, 0xff, 0x7e, 0x3c, 0x18, 0x00}; //爱心-2

  23. //实心箭头
  24. byte Front[8] =   {0x08, 0x1c, 0x3e, 0x7f, 0x1c, 0x1c, 0x1c, 0x1c}; //前
  25. byte back[8] =    {0x1c, 0x1c, 0x1c, 0x1c, 0x7f, 0x3e, 0x1c, 0x08}; //后
  26. byte left[8] =    {0x10, 0x30, 0x7f, 0xff, 0x7f, 0x30, 0x10, 0x00}; //左
  27. byte right[8] =   {0x08, 0x0c, 0xfe, 0xff, 0xfe, 0x0c, 0x08, 0x00}; //右

  28. LedControl lc = LedControl(DIN, CLK, CS, 0);//定义引脚

  29. void setup() {
  30.   lc.shutdown(0, false);      //MAX7219启动时处于省电模式
  31.   lc.setIntensity(0, 15);     // 将亮度设置为最大值
  32.   lc.clearDisplay(0);         // 并清除显示
  33. }

  34. void loop() {

  35.   printByte(smile);
  36.   delay(1000);

  37.   printByte(love_1);
  38.   delay(1000);

  39.   printByte(love_2);
  40.   delay(1000);

  41.   printByte(Front);
  42.   delay(1000);

  43.   printByte(back);
  44.   delay(1000);

  45.   printByte(left);
  46.   delay(1000);

  47.   printByte(right);
  48.   delay(1000);

  49.   printLetter();
  50.   lc.clearDisplay(0);
  51.   delay(1000);
  52. }

  53. void printLetter(){
  54.   printByte(m);
  55.   delay(1000);
  56.   printByte(i);
  57.   delay(1000);
  58.   printByte(r);
  59.   delay(1000);
  60.   printByte(o);
  61.   delay(1000);
  62.   printByte(t);
  63.   delay(1000);
  64.   printByte(e);
  65.   delay(1000);
  66.   printByte(k);
  67.   delay(1000);
  68. }

  69. void printByte(byte character []){
  70.   int i = 0;
  71.   for (i = 0; i < 8; i++)
  72.   {
  73.     lc.setRow(0, i, character[i]);
  74.   }
  75. }
复制代码


 楼主| 发表于 2022-4-29 18:54 | 显示全部楼层
2)实验场景图

11.1-47.jpg

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|Archiver|手机版|好玩手机游戏盒子|196体育|Arduino爱好者

GMT+8, 2023-3-30 06:13 , Processed in 0.086361 second(s), 15 queries .

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表