Arduino爱好者

 找回密码
 立即注册

QQ登录

只需一步,快速开始

楼主: eagler8

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

[复制链接]
发表于 2021-8-20 12:58 | 显示全部楼层
eagler8 发表于 2021-8-20 12:56
需要显示的数值多少位?

第一个数码管  显示3位,  第二个数码管显示3位,第三个数码管显示4位,第四个数码管显示5位   都设置过的
 楼主| 发表于 2021-8-20 15:45 | 显示全部楼层
河边的渔夫 发表于 2021-8-20 12:58
第一个数码管  显示3位,  第二个数码管显示3位,第三个数码管显示4位,第四个数码管显示5位   都设置过 ...

还挺复杂的应用场景
发表于 2021-8-22 22:06 | 显示全部楼层
eagler8 发表于 2021-8-20 15:45
还挺复杂的应用场景

有上位机程序    不复杂 只是  不知道什么原因 会这样   上位机程序里都显示正确 但数码管没反应 ,

上位机显示正确

上位机显示正确
发表于 2021-8-22 22:13 | 显示全部楼层
游戏里和 上位机显示一致

游戏显示 和上位机显示 一致 数码管不显示 挂一个数码管 显示正确

游戏显示 和上位机显示 一致   数码管不显示  挂一个数码管 显示正确
 楼主| 发表于 2021-8-23 10:02 | 显示全部楼层
河边的渔夫 发表于 2021-8-22 22:13
游戏里和 上位机显示一致

这两天我做了几个小实验,发在这里

【Arduino】108种传感器模块系列实验(84)--- 8位LED数码管模块
https://www.arduino.cn/thread-90864-1-1.html
 楼主| 发表于 2021-9-10 18:57 | 显示全部楼层
  【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. #include <LedControl.h>

  14. const int DIN_PIN = 12;
  15. const int CS_PIN = 11;
  16. const int CLK_PIN = 10;

  17. const uint64_t IMAGES[] = {
  18.   0xff000001010000ff, 0xff000003030000ff, 0xff000006060000ff,
  19.   0xff00000c0c0000ff, 0xff000018180000ff, 0xff000030300000ff,
  20.   0xff000060600000ff, 0xff0000c0c00000ff, 0xff000080800000ff,
  21.   0xff0000c0c00000ff, 0xff000060600000ff, 0xff000018180000ff,
  22.   0xff00000c0c0000ff, 0xff000006060000ff, 0xff000003030000ff,
  23.   0xff000001010000ff
  24. };
  25. const int IMAGES_LEN = sizeof(IMAGES) / 8;


  26. LedControl display = LedControl(DIN_PIN, CLK_PIN, CS_PIN);


  27. void setup() {
  28.   display.clearDisplay(0);
  29.   display.shutdown(0, false);
  30.   display.setIntensity(0, 10);
  31. }

  32. void displayImage(uint64_t image) {
  33.   for (int i = 0; i < 8; i++) {
  34.     byte row = (image >> i * 8) & 0xFF;
  35.     for (int j = 0; j < 8; j++) {
  36.       display.setLed(0, i, j, bitRead(row, j));
  37.     }
  38.   }
  39. }

  40. int i = 0;

  41. void loop() {
  42.   displayImage(IMAGES[i]);
  43.   if (++i >= IMAGES_LEN ) {
  44.     i = 0;
  45.   }
  46.   delay(100);
  47. }
复制代码


 楼主| 发表于 2021-9-10 19:10 | 显示全部楼层
实验场景图  动态图  
 楼主| 发表于 2021-9-11 12:45 | 显示全部楼层
  【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. #include <LedControl.h>

  14. int DIN = 12;
  15. int CS =  11;
  16. int CLK = 10;

  17. //Main
  18. byte Design1[8] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,};
  19. byte Design2[8] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,};
  20. byte Design3[8] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x03,};
  21. byte Design4[8] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x03, 0x07,};
  22. byte Design5[8] = {0x00, 0x00, 0x00, 0x00, 0x01, 0x03, 0x07, 0x0F,};
  23. byte Design6[8] = {0x00, 0x00, 0x00, 0x01, 0x03, 0x07, 0x0F, 0x1F,};
  24. byte Design7[8] = {0x00, 0x00, 0x01, 0x03, 0x07, 0x0F, 0x1F, 0x3F,};
  25. byte Design8[8] = {0x00, 0x01, 0x03, 0x07, 0x0F, 0x1F, 0x3F, 0x7F,};
  26. byte Design9[8] = {0x01, 0x03, 0x07, 0x0F, 0x1F, 0x3F, 0x7F, 0xFF,};
  27. byte Design10[8] = {0x03, 0x07, 0x0F, 0x1F, 0x3F, 0x7F, 0xFF, 0xFF,};
  28. byte Design11[8] = {0x07, 0x0F, 0x1F, 0x3F, 0x7F, 0xFF, 0xFF, 0xFF,};
  29. byte Design12[8] = {0x0F, 0x1F, 0x3F, 0x7F, 0xFF, 0xFF, 0xFF, 0xFF,};
  30. byte Design13[8] = {0x1F, 0x3F, 0x7F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,};
  31. byte Design14[8] = {0x3F, 0x7F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,};
  32. byte Design15[8] = {0x7F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,};
  33. byte Design16[8] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,};
  34. byte Design17[8] = {0xBF, 0x7F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,};
  35. byte Design18[8] = {0xAF, 0x5F, 0xBF, 0x7F, 0xFF, 0xFF, 0xFF, 0xFF,};
  36. byte Design19[8] = {0xAB, 0x57, 0xAF, 0x5F, 0xBF, 0x7F, 0xFF, 0xFF,};
  37. byte Design20[8] = {0xAA, 0x55, 0xAB, 0x57, 0xAF, 0x5F, 0xBF, 0x7F,};
  38. byte Design21[8] = {0xAA, 0x55, 0xAA, 0x55, 0xAB, 0x57, 0xAF, 0x5F,};
  39. byte Design22[8] = {0xAA, 0x55, 0xAA, 0x55, 0xAA, 0x55, 0xAB, 0x57,};
  40. byte Design23[8] = {0xAA, 0x55, 0xAA, 0x55, 0xAA, 0x55, 0xAA, 0x55,};

  41. //Blink
  42. byte BlinkOn1[8] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,};
  43. byte BlinkOff1[8] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,};
  44. byte BlinkOn2[8] = {0xAA, 0x55, 0xAA, 0x55, 0xAA, 0x55, 0xAA, 0x55,};
  45. byte BlinkOff2[8] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,};

  46. LedControl lc = LedControl(DIN, CLK, CS, 0);

  47. void setup() {
  48.   lc.shutdown(0, false);      //The MAX72XX is in power-saving mode on startup
  49.   lc.setIntensity(0, 10);     // Set the brightness to maximum value
  50.   lc.clearDisplay(0);         // and clear the display
  51. }

  52. void loop() {
  53.   printByte(Design1);
  54.   delay(100);
  55.   printByte(Design2);
  56.   delay(100);
  57.   printByte(Design3);
  58.   delay(100);
  59.   printByte(Design4);
  60.   delay(100);
  61.   printByte(Design5);
  62.   delay(100);
  63.   printByte(Design6);
  64.   delay(100);
  65.   printByte(Design7);
  66.   delay(100);
  67.   printByte(Design8);
  68.   delay(100);
  69.   printByte(Design9);
  70.   delay(100);
  71.   printByte(Design10);
  72.   delay(100);
  73.   printByte(Design11);
  74.   delay(100);
  75.   printByte(Design12);
  76.   delay(100);
  77.   printByte(Design13);
  78.   delay(100);
  79.   printByte(Design14);
  80.   delay(100);
  81.   printByte(Design15);
  82.   delay(100);
  83.   printByte(Design16);
  84.   delay(100);

  85.   //Blink1
  86.   printByte(BlinkOn1);
  87.   delay(350);
  88.   printByte(BlinkOff1);
  89.   delay(350);
  90.   printByte(BlinkOn1);
  91.   delay(350);
  92.   printByte(BlinkOff1);
  93.   delay(350);
  94.   printByte(BlinkOn1);
  95.   delay(350);

  96.   //Design2
  97.   printByte(Design17);
  98.   delay(100);
  99.   printByte(Design18);
  100.   delay(100);
  101.   printByte(Design19);
  102.   delay(100);
  103.   printByte(Design20);
  104.   delay(100);
  105.   printByte(Design21);
  106.   delay(100);
  107.   printByte(Design22);
  108.   delay(100);
  109.   printByte(Design23);
  110.   delay(100);

  111.   //Blink2
  112.   printByte(BlinkOn2);
  113.   delay(350);
  114.   printByte(BlinkOff2);
  115.   delay(350);
  116.   printByte(BlinkOn2);
  117.   delay(350);
  118.   printByte(BlinkOff2);
  119.   delay(350);
  120. }

  121. void printByte(byte character []){
  122.   int i = 0;
  123.   for (i = 0; i < 8; i++){
  124.     lc.setRow(0, i, character[i]);
  125.   }
  126. }
复制代码


 楼主| 发表于 2021-9-11 12:45 | 显示全部楼层
实验接线图

z801.jpg
 楼主| 发表于 2021-9-11 12:47 | 显示全部楼层
实验场景图  动态图
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

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

GMT+8, 2023-6-1 13:00 , Processed in 0.092371 second(s), 15 queries .

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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