[Diao Ye learns programming] Arduino hands-on (99) --- 8X32 LED dot matrix screen module 3

The reference to 37 sensors and actuators has been widely circulated on the Internet. In fact, there must be more than 37 sensor modules compatible with Arduino. In view of the fact that I have accumulated some sensor and actuator modules on hand, according to the concept of practicing true knowledge (must be done), for the purpose of learning and communication, I am going to try a series of experiments one by one, regardless of success (the program goes through) or not, They will be recorded - small progress or unsolvable problems, hoping to inspire others.

[Arduino] 168 kinds of sensor module series experiments (data code + simulation programming + graphics programming)
Experiment 99: 8X32 LED dot matrix display module MAX7219 output common cathode 5V four-bit dot matrix module

insert image description here
Knowledge points: MAX7219
is a multi-digit LED display driver launched by MAXIM Company in the United States. It uses a 3-wire serial interface to transmit data and can be directly connected to the single-chip interface. Users can easily modify its internal parameters to realize multi-digit LED display. It contains hardware dynamic scanning circuit, BCD decoder, segment driver and bit driver. In addition, it also contains 8X8-bit static RAM inside, which is used to store the display data of 8 figures. Obviously, it can directly drive a 64-segment LED dot matrix display. When multiple MAX7219s are cascaded, more LED dot-matrix displays can be controlled. The displayed data is sent to MAX7219 for display after being processed by the single-chip microcomputer.

The MAX7219/MAX7221 are integrated serial input/output common-cathode display drivers that connect a microprocessor to an 8-digit 7-segment LED display, as well as a bar graph display or 64 individual LEDs. It includes an on-chip B-type BCD encoder, multi-channel scanning circuit, segment driver, and an 8*8 static RAM to store each data. Only one external register is used to set the segment current for each LED. The MAX7221 is compatible with SPI™, QSPI™, and MICROWIRE™, and it has a segment drive that limits the slew current to reduce EMI (electromagnetic interference). A convenient four-wire serial interface can interface with all common microprocessors. Each data address can be updated without rewriting all displays. The MAX7219/MAX7221 also allow the user to choose to encode or not encode each data. The entire device includes a 150µA low-power shutdown mode, analog and digital brightness controls, a scan limit register allowing the user to display 1-8 bits of data, and a detection mode that makes all LEDs illuminate.

insert image description here
8X32 LED dot matrix display module MAX7219 output common cathode 5V four bit dot matrix module

8X32 LED dot matrix display cascade module, MAX7219 is an integrated serial input/output common-cathode display driver, which connects the microprocessor and 8-digit 7-segment digital LED display, and can also be connected to a bar graph display or 64 individual LEDs. It includes an on-chip B-type BCD encoder, multi-channel scanning circuit, segment driver, and an 8*8 static RAM to store each data. Only one external register is used to set the segment current for each LED. A convenient four-wire serial interface can interface with all common microprocessors. Each data address can be updated without rewriting all displays. The MAX7219 also allows the user to choose to encode or not encode each data. The entire device includes a 150µA low-power shutdown mode, analog and digital brightness controls, a scan limit register allowing the user to display 1-8 bits of data, and a detection mode that makes all LEDs illuminate. Only 3 IO ports are needed to drive 1 dot matrix! No flickering when the dot matrix display! Cascading is supported!

insert image description here
8X32 LED dot matrix display module reference circuit schematic diagram

insert image description here
insert image description here
Wiring diagram of Arduino experiment

insert image description here

Experimental open source graphics programming (Mind+, programming while learning)

insert image description here
insert image description here

Experimental open source simulation programming (Linkboy V5.33)

insert image description here
【HuaDiao hands-on】Interesting and fun music visualization series of small projects (08) - four-digit 32-segment dot-matrix screen One of the
projects: 8-segment frequency division 8X8 dot-matrix screen music spectrum light
Pin connection: MAX9814 to A0
MAX7219 UNO
VCC →→→→→ 5V
GND →→→→→ GND
DIN →→→→→ D11 (data, data receiving pin)
CS →→→→→ D10 (load, command receiving pin)
CLK →→→→→ D13 (clock, clock pin)

/*
  【花雕动手做】有趣好玩的音乐可视化系列小项目(08)---四位32段点阵屏
  项目之一:八段分频8X8点阵屏的音乐频谱灯
  接脚连线:MAX9814 接A0
  MAX7219 UNO
  VCC →→→→→ 5V
  GND →→→→→ GND
  DIN →→→→→ D11(数据,数据接收引脚)
  CS →→→→→ D10(负载,命令接收引脚)
  CLK →→→→→ D13(时钟,时钟引脚)
*/

#include "LedControl.h"

/* Led matrix - Max7219 Declared */
LedControl lc = LedControl(11, 13, 10, 1);

const int maxScale = 11;

/* Sensor - Max9812 Declared */
const int sensorPin = A0;
const int sampleWindow = 50; // 50ms = 20Hz
unsigned int sample;

unsigned long startMillis;
unsigned long timeCycle;

unsigned int signalMax = 0;
unsigned int signalMin = 1024;
unsigned char index = 0;

unsigned int peakToPeak[8];
unsigned int displayPeak[8];
unsigned int temp[8] = {
    
    0, 0, 0, 0, 0, 0, 0, 0};
unsigned int signalMaxBuff[8];
unsigned int signalMinBuff[8];


void setup() {
    
    
  // Led matrix
  lc.shutdown(0, false); // bật hiện thị
  lc.setIntensity(0, 2); // chỉnh độ sáng
  lc.clearDisplay(0); // tắt tất cả led

  Serial.begin(9600);
}

void loop() {
    
    
  startMillis = millis();
  //peakToPeak = 0;

  signalMax = 0;
  signalMin = 1024;

  // Get data in 50ms
  while (millis() - startMillis < sampleWindow) {
    
    
    sample = analogRead(sensorPin);

    if (sample < 1024) {
    
    
      if (sample > signalMax) {
    
    
        signalMax = sample;
      }
      if (sample < signalMin) {
    
    
        signalMin = sample;
      }
    }

    // 20Hz - 64Hz - 125Hz - 250Hz - 500Hz - 1kHz (timeCycle = 1/F)(ms)
    timeCycle = millis() - startMillis;
    if (timeCycle == 1 || timeCycle == 2 || timeCycle == 4 || timeCycle == 8
        || timeCycle == 16 || timeCycle == 32 || timeCycle == 40 || timeCycle == 50) {
    
    
      signalMaxBuff[index] = signalMax;
      signalMinBuff[index] = signalMin;
      index = (index + 1) % 8;
      delay(1);
      Serial.println(timeCycle);
    }
  }

  // Delete pointer to array
  index = 0;

  // Calculation after get samples
  for (int i = 0; i < 8; i++) {
    
     // i = row (led matrix)
    // sound level
    peakToPeak[i] = signalMaxBuff[i] - signalMinBuff[i];

    // Map 1v p-p level to the max scale of the display
    displayPeak[i] = map(peakToPeak[i], 0, 1023, 0, maxScale);

    // Show to led matrix
    displayLed(displayPeak[i], i);

    // Led drop down
    if (displayPeak[i] >= temp[i]) {
    
    
      temp[i] = displayPeak[i];
    }
    else {
    
    
      temp[i]--;
    }

    lc.setLed(0, i, temp[i], true);
    delayMicroseconds(10);
  }

}

void displayLed(int displayPeak, int row) {
    
    
  switch (displayPeak) {
    
    
    case 0 : lc.setRow(0, row, 0x80); break;
    case 1 : lc.setRow(0, row, 0xC0); break;
    case 2 : lc.setRow(0, row, 0xE0); break;
    case 3 : lc.setRow(0, row, 0xF0); break;
    case 4 : lc.setRow(0, row, 0xF8); break;
    case 5 : lc.setRow(0, row, 0xFC); break;
    case 6 : lc.setRow(0, row, 0xFE); break;
    case 7 : lc.setRow(0, row, 0xFF); break;
  }
}

Experimental scene dynamic diagram

insert image description here

Experimental video clip

https://v.youku.com/v_show/id_XNTgyMTcwMzUyNA==.html?spm=a2hcb.playlsit.page.1

insert image description here

Guess you like

Origin blog.csdn.net/weixin_41659040/article/details/131990518