[Diao Ye learns programming] Arduino hands-on (104) --- 16X16 dot matrix Chinese character screen module 2

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 sensor module series experiments (data code + simulation programming + graphic programming)
Experiment 104: 16X16 dot matrix UART interface LED Chinese character display module

insert image description here
insert image description here
Knowledge points: The LED dot matrix screen
is composed of LEDs (light emitting diodes), and displays text, pictures, animations, videos, etc. by turning on and off the lamp beads. It is a display device with modular components, usually composed of display modules, control systems and Composition of power system. LED dot matrix display is simple to make and easy to install, and is widely used in various public places, such as car station announcers, advertising screens and bulletin boards.

insert image description here
The display principle
takes a simple 8X8 dot matrix as an example. It is composed of 64 light-emitting diodes, and each light-emitting diode is placed at the intersection of the row line and the column line. When the corresponding row is set to 1 level, a certain column If you set the level to 0, the corresponding diode will be on; if you want to light up the first point, connect pin 9 to high level and pin 13 to low level, then the first point will be on; if you want to turn on the first point If the row is lit, the 9th pin should be connected to high level, and (13, 3, 4, 10, 6, 11, 15, 16) these pins should be connected to low level, then the first row will be lit; To light up the first column, connect pin 13 to low level, and (9, 14, 8, 12, 1, 7, 2, 5) to high level, then the first column will light up.

Generally, we use a dot matrix to display Chinese characters. The 16 16 dot matrix Song font library is used . The so-called 16 16 means that each Chinese character is displayed in an area of ​​16 points in the vertical and horizontal directions. That is to say, four 8 8 dot matrixes are combined to form a 16 16 dot matrix. For example, if you want to display "you", the corresponding dot should be lighted. Since the dot matrix is ​​active at low level on the column line, and at high level on the row line, so if you want to display the word "you", its bit The code information should be reversed, that is, all columns (pin 13 and pin 16) send (0xF7, 0x7F), while the first row (pin 9) sends a 1 signal, and then the first row sends a 0. Then send the data to be displayed in the second line (13 16 pins) to (0xF7, 0x7F), and the second line (14 pins) to send 1 signal. By analogy, as long as the display time interval of each row of data is short enough, using the visual pause function of the human eye, you will see a word "you" after scanning 16 rows of data after sending 16 times of data; the second method of sending data is It is the same reason that the font signal is sent to the row line and then the column line is scanned. Also use the word "you" to illustrate, 16 lines (9, 14, 8, 12, 1, 7, 2, 5) send (, 0x00, 0x00) and the first column (13 feet) send "0". Scan the second column in the same way. When the data is sent 16 times on the row line and the column line is scanned 16 times, a word "you" will be displayed.

insert image description here
[Arduino] 168 kinds of sensor module series experiments (data code + simulation programming + graphics programming)
Experiment 104: 16X16 dot matrix serial port LED Chinese character display module UART interface
1. Installation library: marde
2. Project: display "smart" Word
3, connection:
VDD → 5V
GND → GND
TXD → D0
RXD → D1

/*
【Arduino】108种传感器模块系列实验(资料+代码+图形+仿真)
实验一百零八: 16X16点阵串口LED汉字显示屏模块UART接口
1、安装库:marde
2、项目:显示“智”字
3、连线:
VDD  →  5V
GND → GND
TXD  →  D0
RXD  →  D1
*/

#include <MdLep16X16.h>

byte message[][2]
={
    
    
  {
    
    0x20,0x00},//line_0
  {
    
    0x3e,0x7c},//line_1
  {
    
    0x48,0x44},//line_2
  {
    
    0x08,0x44},//line_3
  {
    
    0xff,0x44},//line_4
  {
    
    0x14,0x44},//line_5
  {
    
    0x22,0x7c},//line_6
  {
    
    0x40,0x00},//line_7
  {
    
    0x1f,0xf0},//line_8
  {
    
    0x10,0x10},//line_9
  {
    
    0x10,0x10},//line_10
  {
    
    0x1f,0xf0},//line_11
  {
    
    0x10,0x10},//line_12
  {
    
    0x10,0x10},//line_13
  {
    
    0x1f,0xf0},//line_14
  {
    
    0x10,0x10},//line_15
};

MdLep16X16 mdLep(0xFF, 0xFF, 0xFF, 0xFF);

void setup() {
    
    
  // put your setup code here, to run once:
  Serial.begin(9600);
  delay(1000);
  mdLep.loadScreen((byte*)message);
}

void loop() {
    
    
  // put your main code here, to run repeatedly:   
}

Arduino experiment scene diagram

insert image description here

[Arduino] 168 kinds of sensor module series experiments (data code + simulation programming + graphics programming)
one of the projects: eight-segment frequency division 8X8 dot matrix screen music spectrum light

Experimental open source code

/*
  【花雕动手做】有趣好玩的音乐可视化系列小项目(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;
  }
}

[Arduino] 168 kinds of sensor module series experiments (data code + simulation programming + graphics programming)
Project 2: Multi-file arduino FFT floating-point 32-segment spectrum analyzer

Experimental video clip

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

Experiment Video Clip 2

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

Arduino experiment scene diagram

insert image description here

insert image description here

Experimental scene diagram
Use a DuPont line to lead out the D2 pin as a touch switch, which can switch between five modes of displaying the spectrum, and there are three more in the back

insert image description here

Project 2: Multi-file arduinoFFT floating-point 32-segment spectrum analyzer

Experiment Video Clip 3

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

Experimental scene dynamic diagram

insert image description here

Project 2: Multi-file arduinoFFT floating-point 32-segment spectrum analyzer

Experiment Video Clip 4

https://v.youku.com/v_show/id_XNTgyMTQ2NDIzMg==.html?spm=a2hcb.playlsit.page.7

Experimental scene dynamic figure 4

insert image description here

Project 2: Multi-file arduinoFFT floating-point 32-segment spectrum analyzer

Experiment Video Clip 5

https://v.youku.com/v_show/id_XNTgyMTc5OTQ0MA==.html?spm=a2hcb.playlsit.page.5

Experimental scene dynamic diagram 5

insert image description here

[Arduino] 168 kinds of sensor module series experiments (data code + simulation programming + graphics programming)
project three: red and green 32-segment cascaded spectrum dot matrix screen lights (FFT algorithm)

Experimental open source code

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

#include <arduinoFFT.h>

#include <MD_MAX72xx.h>

#include <SPI.h>

MD_MAX72XX disp = MD_MAX72XX(MD_MAX72XX::FC16_HW, 10, 1);

arduinoFFT FFT = arduinoFFT();

double realComponent[64];

double imagComponent[64];

int spectralHeight[] = {
    
    0b00000000, 0b10000000, 0b11000000,

                        0b11100000, 0b11110000, 0b11111000,

                        0b11111100, 0b11111110, 0b11111111
                       };

int index, c, value;

void setup()

{
    
    

  disp.begin();

  Serial.begin(9600);

}

void loop()

{
    
    

  int sensitivity = map(analogRead(A0), 0, 1023, 50, 100);

  Serial.println (analogRead(A0));

  for (int i = 0; i < 64; i++)

  {
    
    

    realComponent[i] = analogRead(A7) / sensitivity;

    imagComponent[i] = 0;

  }

  FFT.Windowing(realComponent, 64, FFT_WIN_TYP_HAMMING, FFT_FORWARD);

  FFT.Compute(realComponent, imagComponent, 64, FFT_FORWARD);

  FFT.ComplexToMagnitude(realComponent, imagComponent, 64);

  for (int i = 0; i < 32; i++)

  {
    
    

    realComponent[i] = constrain(realComponent[i], 0, 80);

    realComponent[i] = map(realComponent[i], 0, 80, 0, 8);

    index = realComponent[i];

    value = spectralHeight[index];

    c = 31 - i;

    disp.setColumn(c, value);

  }

}

[Arduino] 168 kinds of sensor module series experiments (data code + simulation programming + graphics programming)
project three: red and green 32-segment cascaded spectrum dot matrix screen lights (FFT algorithm)

Experimental video clip 1
https://v.youku.com/v_show/id_XNTgyMjA0Mjg0NA==.html?spm=a2hcb.playlsit.page.3

Experimental scene dynamic diagram

insert image description here

Guess you like

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