Arduino爱好者

 找回密码
 立即注册

QQ登录

只需一步,快速开始

楼主: eagler8

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

[复制链接]
 楼主| 发表于 2021-10-12 18:21 | 显示全部楼层
  【Arduino】168种传感器模块系列实验(资料代码+仿真编程+图形编程)
  实验二十二:MAX7219点阵显示模块(8X8 LED共阴)
  项目三十五:逐点排列

  实验开源代码

  1. /*
  2.   【Arduino】168种传感器模块系列实验(资料代码+仿真编程+图形编程)
  3.   实验二十二:MAX7219点阵显示模块(8X8 LED共阴)
  4.   项目三十五:逐点排列
  5.   接脚连线:
  6.   MAX7219      UNO
  7.   VCC  →→→→→ 5V
  8.   GND  →→→→→ GND
  9.   DIN  →→→→→ D12(数据,数据接收引脚)
  10.   CS   →→→→→ D11(负载,命令接收引脚)
  11.   CLK  →→→→→ D10(时钟,时钟引脚)
  12. */

  13. //We always have to include the library
  14. #include "LedControlMS.h"

  15. /*
  16. Now we need a LedControl to work with.
  17. ***** These pin numbers will probably not work with your hardware *****
  18. pin 12 is connected to the DataIn
  19. pin 11 is connected to the CLK
  20. pin 10 is connected to LOAD
  21. We have only a single MAX72XX.
  22. */
  23. LedControl lc=LedControl(12,10,11,1);

  24. /* we always wait a bit between updates of the display */
  25. unsigned long delaytime=100;

  26. void setup() {
  27.   /*
  28.    The MAX72XX is in power-saving mode on startup,
  29.    we have to do a wakeup call
  30.    */
  31.   lc.shutdown(0,false);
  32.   /* Set the brightness to a medium values */
  33.   lc.setIntensity(0,8);
  34.   /* and clear the display */
  35.   lc.clearDisplay(0);
  36. }

  37. /*
  38. This method will display the characters for the
  39. word "Arduino" one after the other on the matrix.
  40. (you need at least 5x7 leds to see the whole chars)
  41. */
  42. void writeArduinoOnMatrix() {
  43.   /* here is the data for the characters */
  44.   byte a[5]={B01111110,B10001000,B10001000,B10001000,B01111110};
  45.   byte r[5]={B00111110,B00010000,B00100000,B00100000,B00010000};
  46.   byte d[5]={B00011100,B00100010,B00100010,B00010010,B11111110};
  47.   byte u[5]={B00111100,B00000010,B00000010,B00000100,B00111110};
  48.   byte i[5]={B00000000,B00100010,B10111110,B00000010,B00000000};
  49.   byte n[5]={B00111110,B00010000,B00100000,B00100000,B00011110};
  50.   byte o[5]={B00011100,B00100010,B00100010,B00100010,B00011100};

  51.   /* now display them one by one with a small delay */
  52.   lc.setRow(0,0,a[0]);
  53.   lc.setRow(0,1,a[1]);
  54.   lc.setRow(0,2,a[2]);
  55.   lc.setRow(0,3,a[3]);
  56.   lc.setRow(0,4,a[4]);
  57.   delay(delaytime);
  58.   lc.setRow(0,0,r[0]);
  59.   lc.setRow(0,1,r[1]);
  60.   lc.setRow(0,2,r[2]);
  61.   lc.setRow(0,3,r[3]);
  62.   lc.setRow(0,4,r[4]);
  63.   delay(delaytime);
  64.   lc.setRow(0,0,d[0]);
  65.   lc.setRow(0,1,d[1]);
  66.   lc.setRow(0,2,d[2]);
  67.   lc.setRow(0,3,d[3]);
  68.   lc.setRow(0,4,d[4]);
  69.   delay(delaytime);
  70.   lc.setRow(0,0,u[0]);
  71.   lc.setRow(0,1,u[1]);
  72.   lc.setRow(0,2,u[2]);
  73.   lc.setRow(0,3,u[3]);
  74.   lc.setRow(0,4,u[4]);
  75.   delay(delaytime);
  76.   lc.setRow(0,0,i[0]);
  77.   lc.setRow(0,1,i[1]);
  78.   lc.setRow(0,2,i[2]);
  79.   lc.setRow(0,3,i[3]);
  80.   lc.setRow(0,4,i[4]);
  81.   delay(delaytime);
  82.   lc.setRow(0,0,n[0]);
  83.   lc.setRow(0,1,n[1]);
  84.   lc.setRow(0,2,n[2]);
  85.   lc.setRow(0,3,n[3]);
  86.   lc.setRow(0,4,n[4]);
  87.   delay(delaytime);
  88.   lc.setRow(0,0,o[0]);
  89.   lc.setRow(0,1,o[1]);
  90.   lc.setRow(0,2,o[2]);
  91.   lc.setRow(0,3,o[3]);
  92.   lc.setRow(0,4,o[4]);
  93.   delay(delaytime);
  94.   lc.setRow(0,0,0);
  95.   lc.setRow(0,1,0);
  96.   lc.setRow(0,2,0);
  97.   lc.setRow(0,3,0);
  98.   lc.setRow(0,4,0);
  99.   delay(delaytime);
  100. }

  101. /*
  102.   This function lights up a some Leds in a row.
  103. The pattern will be repeated on every row.
  104. The pattern will blink along with the row-number.
  105. row number 4 (index==3) will blink 4 times etc.
  106. */
  107. void rows() {
  108.   for(int row=0;row<8;row++) {
  109.     delay(delaytime);
  110.     lc.setRow(0,row,B10100000);
  111.     delay(delaytime);
  112.     lc.setRow(0,row,(byte)0);
  113.     for(int i=0;i<row;i++) {
  114.       delay(delaytime);
  115.       lc.setRow(0,row,B10100000);
  116.       delay(delaytime);
  117.       lc.setRow(0,row,(byte)0);
  118.     }
  119.   }
  120. }

  121. /*
  122.   This function lights up a some Leds in a column.
  123. The pattern will be repeated on every column.
  124. The pattern will blink along with the column-number.
  125. column number 4 (index==3) will blink 4 times etc.
  126. */
  127. void columns() {
  128.   for(int col=0;col<8;col++) {
  129.     delay(delaytime);
  130.     lc.setColumn(0,col,B10100000);
  131.     delay(delaytime);
  132.     lc.setColumn(0,col,(byte)0);
  133.     for(int i=0;i<col;i++) {
  134.       delay(delaytime);
  135.       lc.setColumn(0,col,B10100000);
  136.       delay(delaytime);
  137.       lc.setColumn(0,col,(byte)0);
  138.     }
  139.   }
  140. }

  141. /*
  142. This function will light up every Led on the matrix.
  143. The led will blink along with the row-number.
  144. row number 4 (index==3) will blink 4 times etc.
  145. */
  146. void single() {
  147.   for(int row=0;row<8;row++) {
  148.     for(int col=0;col<8;col++) {
  149.       delay(delaytime);
  150.       lc.setLed(0,row,col,true);
  151.       delay(delaytime);
  152.       for(int i=0;i<col;i++) {
  153.         lc.setLed(0,row,col,false);
  154.         delay(delaytime);
  155.         lc.setLed(0,row,col,true);
  156.         delay(delaytime);
  157.       }
  158.     }
  159.   }
  160. }

  161. void loop() {
  162.   writeArduinoOnMatrix();
  163.   rows();
  164.   columns();
  165.   single();
  166. }
复制代码


 楼主| 发表于 2021-10-12 18:22 | 显示全部楼层
实验场景动态图

36.gif
 楼主| 发表于 2021-10-12 18:29 | 显示全部楼层
  【Arduino】168种传感器模块系列实验(资料代码+仿真编程+图形编程)
  实验二十二:MAX7219点阵显示模块(8X8 LED共阴)
  项目三十六:快速扫描矩阵所以点

  实验开源代码

  1. /*
  2.   【Arduino】168种传感器模块系列实验(资料代码+仿真编程+图形编程)
  3.   实验二十二:MAX7219点阵显示模块(8X8 LED共阴)
  4.   项目三十六:快速扫描矩阵所以点
  5.   接脚连线:
  6.   MAX7219      UNO
  7.   VCC  →→→→→ 5V
  8.   GND  →→→→→ GND
  9.   DIN  →→→→→ D12(数据,数据接收引脚)
  10.   CS   →→→→→ D11(负载,命令接收引脚)
  11.   CLK  →→→→→ D10(时钟,时钟引脚)
  12. */

  13. //We always have to include the library
  14. #include "LedControlMS.h"

  15. /*
  16. Now we need a LedControl to work with.
  17. ***** These pin numbers will probably not work with your hardware *****
  18. pin 12 is connected to the DataIn
  19. pin 11 is connected to the CLK
  20. pin 10 is connected to LOAD
  21. ***** Please set the number of devices you have *****
  22. But the maximum default of 8 MAX72XX wil also work.
  23. */
  24. LedControl lc=LedControl(12,10,11,1);

  25. /* we always wait a bit between updates of the display */
  26. unsigned long delaytime=10;

  27. /*
  28. This time we have more than one device.
  29. But all of them have to be initialized
  30. individually.
  31. */
  32. void setup() {
  33.   //we have already set the number of devices when we created the LedControl
  34.   int devices=lc.getDeviceCount();
  35.   //we have to init all devices in a loop
  36.   for(int address=0;address<devices;address++) {
  37.     /*The MAX72XX is in power-saving mode on startup*/
  38.     lc.shutdown(address,false);
  39.     /* Set the brightness to a medium values */
  40.     lc.setIntensity(address,8);
  41.     /* and clear the display */
  42.     lc.clearDisplay(address);
  43.   }
  44. }

  45. void loop() {
  46.   //read the number cascaded devices
  47.   int devices=lc.getDeviceCount();
  48.   
  49.   //we have to init all devices in a loop
  50.   for(int row=0;row<8;row++) {
  51.     for(int col=0;col<8;col++) {
  52.       for(int address=0;address<devices;address++) {
  53.         delay(delaytime);
  54.         lc.setLed(address,row,col,true);
  55.         delay(delaytime);
  56.         lc.setLed(address,row,col,false);
  57.       }
  58.     }
  59.   }
  60. }
复制代码


 楼主| 发表于 2021-10-12 18:36 | 显示全部楼层
  实验场景动态图

39.gif
 楼主| 发表于 2021-10-12 18:49 | 显示全部楼层
  【Arduino】168种传感器模块系列实验(资料代码+仿真编程+图形编程)
  实验二十二:MAX7219点阵显示模块(8X8 LED共阴)
  项目三十七:动态字符串

  实验开源代码

  1. /*
  2.   【Arduino】168种传感器模块系列实验(资料代码+仿真编程+图形编程)
  3.   实验二十二:MAX7219点阵显示模块(8X8 LED共阴)
  4.   项目三十七:动态字符串
  5.   接脚连线:
  6.   MAX7219      UNO
  7.   VCC  →→→→→ 5V
  8.   GND  →→→→→ GND
  9.   DIN  →→→→→ D12(数据,数据接收引脚)
  10.   CS   →→→→→ D11(负载,命令接收引脚)
  11.   CLK  →→→→→ D10(时钟,时钟引脚)
  12. */

  13. //We always have to include the library
  14. #include "LedControlMS.h"

  15. /*
  16. Now we need a LedControl to work with.
  17. ***** These pin numbers will probably not work with your hardware *****
  18. pin 12 is connected to the DataIn
  19. pin 11 is connected to the CLK
  20. pin 10 is connected to LOAD
  21. We have only a single MAX72XX.
  22. */
  23. LedControl lc=LedControl(12,10,11,1);

  24. /* we always wait a bit between updates of the display */
  25. unsigned long delaytime=250;

  26. void setup() {
  27.   /*
  28.    The MAX72XX is in power-saving mode on startup,
  29.    we have to do a wakeup call
  30.    */
  31.   lc.shutdown(0,false);
  32.   /* Set the brightness to a medium values */
  33.   lc.setIntensity(0,8);
  34.   /* and clear the display */
  35.   lc.clearDisplay(0);
  36. }


  37. /*
  38. This method will display the characters for the
  39. word "Arduino" one after the other on digit 0.
  40. */
  41. void writeArduinoOn7Segment() {
  42.   lc.setChar(2,0,'a',false);
  43.   delay(delaytime);
  44.   lc.setRow(2,0,0x05);
  45.   delay(delaytime);
  46.   lc.setChar(2,0,'d',false);
  47.   delay(delaytime);
  48.   lc.setRow(2,0,0x1c);
  49.   delay(delaytime);
  50.   lc.setRow(2,0,B00010000);
  51.   delay(delaytime);
  52.   lc.setRow(2,0,0x15);
  53.   delay(delaytime);
  54.   lc.setRow(2,0,0x1D);
  55.   delay(delaytime);
  56.   lc.clearDisplay(0);
  57.   delay(delaytime);
  58. }

  59. /*
  60.   This method will scroll all the hexa-decimal
  61. numbers and letters on the display. You will need at least
  62. four 7-Segment digits. otherwise it won't really look that good.
  63. */
  64. void scrollDigits() {
  65.   for(int i=0;i<13;i++) {
  66.     lc.setDigit(0,3,i,false);
  67.     lc.setDigit(0,2,i+1,false);
  68.     lc.setDigit(0,1,i+2,false);
  69.     lc.setDigit(0,0,i+3,false);
  70.     delay(delaytime);
  71.   }
  72.   lc.clearDisplay(0);
  73.   delay(delaytime);
  74. }

  75. void loop() {
  76.   writeArduinoOn7Segment();
  77.   scrollDigits();
  78. }
复制代码


 楼主| 发表于 2022-2-24 11:25 | 显示全部楼层
用3个I/O口来控制64个LED|MAX-7219介绍

https://www.bilibili.com/video/B ... id_from=333.337.0.0



 楼主| 发表于 2022-2-24 11:26 | 显示全部楼层
【Arduino】8x8点阵屏使用教程 MAX7219

https://www.bilibili.com/video/B ... id_from=333.337.0.0

 楼主| 发表于 2022-2-24 11:28 | 显示全部楼层
Arduino点阵文字(中) 8x8 LED Matrix MAX7219 Tutorial with Scrolling Text



https://www.bilibili.com/video/BV1Et411k7U2?from=search&seid=4477785334025497564&spm_id_from=333.337.0.0


 楼主| 发表于 2022-2-24 11:29 | 显示全部楼层
8分钟了解集成电路MAX7219控制点阵屏原理及无依赖库在Arduino上的使用https://www.bilibili.com/video/B ... id_from=333.337.0.0
 楼主| 发表于 2022-2-24 11:30 | 显示全部楼层
30元自制Max7219点阵B数显示时钟

https://www.bilibili.com/video/B ... id_from=333.337.0.0

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

本版积分规则

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

GMT+8, 2023-3-30 07:14 , Processed in 0.083135 second(s), 15 queries .

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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