The reference to 37 sensors and modules 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, in accordance with the concept of true knowledge (must be hands-on), for the purpose of learning and communication, here I am going to try and do more experiments one by one. Whether it is successful or not, it will be recorded ——Small progress or unsolvable problems, I hope to be able to throw bricks and spark jade.
[Arduino] 168 kinds of sensor module series experiments (data code + simulation programming + graphics programming)
Experiment 163: 6mm large size 8x8 LED square lattice module can be cascaded red, green, blue and white optional 8 levels of brightness
[Arduino] 168 kinds of sensor module series experiments (data code + simulation programming + graphic programming)
6mm large size 8x8 LED square grid lattice module can be cascaded red, green, blue and white optional 8-level brightness
Item 30: Display the number "1 in turn - 9" and Chinese "中", "国"
experimental open source code
/*
【Arduino】168种传感器模块系列实验(资料代码+仿真编程+图形编程)
实验一百七十六:6mm大尺寸8x8LED方块方格点阵模块 可级联 红绿蓝白色 可选8级亮度
项目三十:轮流显示数字 “1 - 9” 以及中文 “中”,“国”
接脚连线:
MAX7219 UNO
VCC →→→→→ 5V
GND →→→→→ GND
DIN →→→→→ D12(数据,数据接收引脚)
CS →→→→→ D11(负载,命令接收引脚)
CLK →→→→→ D10(时钟,时钟引脚)
*/
int clk = 10;
int cs = 11;
int din = 12;
unsigned char disp1[12][8] = {
{
0x3C, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x3C}, //0
{
0x08, 0x18, 0x28, 0x08, 0x08, 0x08, 0x08, 0x08}, //1
{
0x7E, 0x2, 0x2, 0x7E, 0x40, 0x40, 0x40, 0x7E}, //2
{
0x3E, 0x2, 0x2, 0x3E, 0x2, 0x2, 0x3E, 0x0}, //3
{
0x8, 0x18, 0x28, 0x48, 0xFE, 0x8, 0x8, 0x8}, //4
{
0x3C, 0x20, 0x20, 0x3C, 0x4, 0x4, 0x3C, 0x0}, //5
{
0x3C, 0x20, 0x20, 0x3C, 0x24, 0x24, 0x3C, 0x0}, //6
{
0x3E, 0x22, 0x4, 0x8, 0x8, 0x8, 0x8, 0x8}, //7
{
0x0, 0x3E, 0x22, 0x22, 0x3E, 0x22, 0x22, 0x3E}, //8
{
0x3E, 0x22, 0x22, 0x3E, 0x2, 0x2, 0x2, 0x3E}, //9
{
0x08, 0x7F, 0x49, 0x49, 0x7F, 0x08, 0x08, 0x08}, //中
{
0xFE, 0xFE, 0x92, 0xFE, 0x9A, 0xFE, 0x82, 0xFE}, //国
};
void setup() {
//设置引脚为输出
pinMode(cs, OUTPUT);
pinMode(clk, OUTPUT);
pinMode(din, OUTPUT);
//初始化MAX7219
Init_MAX7219();
}
void loop() {
char i, j;
//字体扫描显示
for (j = 0; j < 12; j++)
{
for (i = 1; i < 9; i++)
{
Write_Max7219(i, disp1[j][i - 1]);
delay(20);
}
delay(50);
}
}
void Write_Max7219_byte(char DATA)
{
char i;
digitalWrite(cs, 0);
for (i = 8; i >= 1; i--)
{
digitalWrite(clk, 0);
if ((DATA & 0x80) > 0) {
digitalWrite(din, 1);
} else {
digitalWrite(din, 0);
}
//提取最高位给DIN端口
DATA = DATA << 1; //左移一位
digitalWrite(clk, 1);
}
}
void Write_Max7219(char address, char dat)
{
digitalWrite(cs, 0);
Write_Max7219_byte(address); //写入地址,编号
Write_Max7219_byte(dat); //写入数据,即显示数字
digitalWrite(cs, 1);
}
void Init_MAX7219(void)
{
Write_Max7219(0x09, 0x00); //译码方式:BCD码
Write_Max7219(0x0a, 0x01); //亮度
Write_Max7219(0x0b, 0x07); //扫描界限;显示
Write_Max7219(0x0c, 0x01); //掉电模式:0,普通模式:1
Write_Max7219(0x0f, 0x00);
delay(50); //显示测试:1;测试结束,正常显示:0
}
6mm large size 8x8 LED square lattice module can be cascaded with red, green, blue and white optional 8-level brightness
Item 30: Display numbers "1 - 9" and Chinese "中" and "国" in turn
Experimental scene pictures
6mm large size 8x8 LED square lattice module can be cascaded with red, green, blue and white optional 8-level brightness
Project 31: Open
source code for three-color LED experiment using Matrix library
/*
【Arduino】168种传感器模块系列实验(资料代码+仿真编程+图形编程)
6mm大尺寸8x8LED方块方格点阵模块 可级联 红绿蓝白色 可选8级亮度
项目三十一:使用Matrix库的三色LED
接脚连线:
MAX7219 UNO
VCC →→→→→ 5V
GND →→→→→ GND
DIN →→→→→ D12(数据,数据接收引脚)
CS →→→→→ D11(负载,命令接收引脚)
CLK →→→→→ D10(时钟,时钟引脚)
*/
#include <Sprite.h> // Sprite before Matrix
#include <Matrix.h>
//DIN, CLK, CS, #chips
Matrix myLeds = Matrix(12, 10, 11, 3);
Sprite letter_D = Sprite(6, 8,
B111100,
B111110,
B110111,
B110011,
B110011,
B110111,
B111110,
B111100
);
Sprite letter_E = Sprite(5, 8,
B11111,
B11111,
B11000,
B11110,
B11110,
B11000,
B11111,
B11111
);
Sprite letter_L = Sprite(5, 8,
B11000,
B11000,
B11000,
B11000,
B11000,
B11000,
B11111,
B11111
);
void setup() {
myLeds.setBrightness(0);
}
void loop() {
myLeds.clear();
delay(1000);
myLeds.write(17, 0, letter_L);
delay(1000);
myLeds.write(9, 0, letter_E);
delay(1000);
myLeds.write(1, 0, letter_D);
delay(1000);
}
6mm large size 8x8 LED square lattice module can be cascaded with red, green, blue and white optional 8-level brightness
Project 31: Three-color LED using Matrix library
Experimental scene pictures
Several functions of the Matrix library
Basic usage, pixels only
Matrix myLeds = Matrix(DIN,CLK,LOAD,numChips);
Create an instance of the Matrix object with a name of your choosing. DIN, CLK and LOAD are the pin numbers to which these signals are connected. Multiple objects can be created if multiple individually connected MAX7219 chips are connected.
myLeds.clear();
Clears the entire display.
myLeds.setBrightness(15);
Set display brightness, from 0 to 15 (brightest).
myLeds.write(x,y,value);
Change individual pixels. For off, the value should be LOW, for on, the value should be HIGH.
Basic usage, use Sprite
Sprite myIcon = Sprite(宽度,高度,B11000,B11000,B11111,B11111);
Create a sprite object. You can create as many sprites as you want, each with a unique name. The width should match the number of bits in each data value, and the height should match the number of data values.
myLeds.write(x,y,myIcon);
Draws a blinking sprite on the display.
The Sprite library allows the creation of image sprites for use with the Matrix library
Sprite
Start the LCD library.
width()
Returns the width of the sprite in pixels.
height()
Returns the height of the sprite in pixels.
write()
Write data to the x,y position of the sprite.
read()
Returns the data stored at the sprite's x,y position.
6mm large size 8x8 LED square grid dot matrix module can be cascaded red, green, blue and white optional 8-level brightness
Project 32: Establish letter library, horizontal scrolling text display (three cascaded)
experimental open source code
/*
【Arduino】168种传感器模块系列实验(资料代码+仿真编程+图形编程)
6mm大尺寸8x8LED方块方格点阵模块 可级联 红绿蓝白色 可选8级亮度
项目三十二:建立字母库,横式滚动文本显示(三级联)
接线接脚:
MAX7219 UNO
VCC →→→→→ 5V
GND →→→→→ GND
DIN →→→→→ D12(数据,数据接收引脚)
CS →→→→→ D11(负载,命令接收引脚)
CLK →→→→→ D10(时钟,时钟引脚)
*/
#include <MaxMatrix.h>
#include <avr/pgmspace.h>
PROGMEM const unsigned char CH[] = {
3, 8, B00000000, B00000000, B00000000, B00000000, B00000000, // space
1, 8, B01011111, B00000000, B00000000, B00000000, B00000000, // !
3, 8, B00000011, B00000000, B00000011, B00000000, B00000000, // "
5, 8, B00010100, B00111110, B00010100, B00111110, B00010100, // #
4, 8, B00100100, B01101010, B00101011, B00010010, B00000000, // $
5, 8, B01100011, B00010011, B00001000, B01100100, B01100011, // %
5, 8, B00110110, B01001001, B01010110, B00100000, B01010000, // &
1, 8, B00000011, B00000000, B00000000, B00000000, B00000000, // '
3, 8, B00011100, B00100010, B01000001, B00000000, B00000000, // (
3, 8, B01000001, B00100010, B00011100, B00000000, B00000000, // )
5, 8, B00101000, B00011000, B00001110, B00011000, B00101000, // *
5, 8, B00001000, B00001000, B00111110, B00001000, B00001000, // +
2, 8, B10110000, B01110000, B00000000, B00000000, B00000000, // ,
4, 8, B00001000, B00001000, B00001000, B00001000, B00000000, // -
2, 8, B01100000, B01100000, B00000000, B00000000, B00000000, // .
4, 8, B01100000, B00011000, B00000110, B00000001, B00000000, // /
4, 8, B00111110, B01000001, B01000001, B00111110, B00000000, // 0
3, 8, B01000010, B01111111, B01000000, B00000000, B00000000, // 1
4, 8, B01100010, B01010001, B01001001, B01000110, B00000000, // 2
4, 8, B00100010, B01000001, B01001001, B00110110, B00000000, // 3
4, 8, B00011000, B00010100, B00010010, B01111111, B00000000, // 4
4, 8, B00100111, B01000101, B01000101, B00111001, B00000000, // 5
4, 8, B00111110, B01001001, B01001001, B00110000, B00000000, // 6
4, 8, B01100001, B00010001, B00001001, B00000111, B00000000, // 7
4, 8, B00110110, B01001001, B01001001, B00110110, B00000000, // 8
4, 8, B00000110, B01001001, B01001001, B00111110, B00000000, // 9
2, 8, B01010000, B00000000, B00000000, B00000000, B00000000, // :
2, 8, B10000000, B01010000, B00000000, B00000000, B00000000, // ;
3, 8, B00010000, B00101000, B01000100, B00000000, B00000000, // <
3, 8, B00010100, B00010100, B00010100, B00000000, B00000000, // =
3, 8, B01000100, B00101000, B00010000, B00000000, B00000000, // >
4, 8, B00000010, B01011001, B00001001, B00000110, B00000000, // ?
5, 8, B00111110, B01001001, B01010101, B01011101, B00001110, // @
4, 8, B01111110, B00010001, B00010001, B01111110, B00000000, // A
4, 8, B01111111, B01001001, B01001001, B00110110, B00000000, // B
4, 8, B00111110, B01000001, B01000001, B00100010, B00000000, // C
4, 8, B01111111, B01000001, B01000001, B00111110, B00000000, // D
4, 8, B01111111, B01001001, B01001001, B01000001, B00000000, // E
4, 8, B01111111, B00001001, B00001001, B00000001, B00000000, // F
4, 8, B00111110, B01000001, B01001001, B01111010, B00000000, // G
4, 8, B01111111, B00001000, B00001000, B01111111, B00000000, // H
3, 8, B01000001, B01111111, B01000001, B00000000, B00000000, // I
4, 8, B00110000, B01000000, B01000001, B00111111, B00000000, // J
4, 8, B01111111, B00001000, B00010100, B01100011, B00000000, // K
4, 8, B01111111, B01000000, B01000000, B01000000, B00000000, // L
5, 8, B01111111, B00000010, B00001100, B00000010, B01111111, // M
5, 8, B01111111, B00000100, B00001000, B00010000, B01111111, // N
4, 8, B00111110, B01000001, B01000001, B00111110, B00000000, // O
4, 8, B01111111, B00001001, B00001001, B00000110, B00000000, // P
4, 8, B00111110, B01000001, B01000001, B10111110, B00000000, // Q
4, 8, B01111111, B00001001, B00001001, B01110110, B00000000, // R
4, 8, B01000110, B01001001, B01001001, B00110010, B00000000, // S
5, 8, B00000001, B00000001, B01111111, B00000001, B00000001, // T
4, 8, B00111111, B01000000, B01000000, B00111111, B00000000, // U
5, 8, B00001111, B00110000, B01000000, B00110000, B00001111, // V
5, 8, B00111111, B01000000, B00111000, B01000000, B00111111, // W
5, 8, B01100011, B00010100, B00001000, B00010100, B01100011, // X
5, 8, B00000111, B00001000, B01110000, B00001000, B00000111, // Y
4, 8, B01100001, B01010001, B01001001, B01000111, B00000000, // Z
2, 8, B01111111, B01000001, B00000000, B00000000, B00000000, // [
4, 8, B00000001, B00000110, B00011000, B01100000, B00000000, // \ backslash
2, 8, B01000001, B01111111, B00000000, B00000000, B00000000, // ]
3, 8, B00000010, B00000001, B00000010, B00000000, B00000000, // hat
4, 8, B01000000, B01000000, B01000000, B01000000, B00000000, // _
2, 8, B00000001, B00000010, B00000000, B00000000, B00000000, // `
4, 8, B00100000, B01010100, B01010100, B01111000, B00000000, // a
4, 8, B01111111, B01000100, B01000100, B00111000, B00000000, // b
4, 8, B00111000, B01000100, B01000100, B00101000, B00000000, // c
4, 8, B00111000, B01000100, B01000100, B01111111, B00000000, // d
4, 8, B00111000, B01010100, B01010100, B00011000, B00000000, // e
3, 8, B00000100, B01111110, B00000101, B00000000, B00000000, // f
4, 8, B10011000, B10100100, B10100100, B01111000, B00000000, // g
4, 8, B01111111, B00000100, B00000100, B01111000, B00000000, // h
3, 8, B01000100, B01111101, B01000000, B00000000, B00000000, // i
4, 8, B01000000, B10000000, B10000100, B01111101, B00000000, // j
4, 8, B01111111, B00010000, B00101000, B01000100, B00000000, // k
3, 8, B01000001, B01111111, B01000000, B00000000, B00000000, // l
5, 8, B01111100, B00000100, B01111100, B00000100, B01111000, // m
4, 8, B01111100, B00000100, B00000100, B01111000, B00000000, // n
4, 8, B00111000, B01000100, B01000100, B00111000, B00000000, // o
4, 8, B11111100, B00100100, B00100100, B00011000, B00000000, // p
4, 8, B00011000, B00100100, B00100100, B11111100, B00000000, // q
4, 8, B01111100, B00001000, B00000100, B00000100, B00000000, // r
4, 8, B01001000, B01010100, B01010100, B00100100, B00000000, // s
3, 8, B00000100, B00111111, B01000100, B00000000, B00000000, // t
4, 8, B00111100, B01000000, B01000000, B01111100, B00000000, // u
5, 8, B00011100, B00100000, B01000000, B00100000, B00011100, // v
5, 8, B00111100, B01000000, B00111100, B01000000, B00111100, // w
5, 8, B01000100, B00101000, B00010000, B00101000, B01000100, // x
4, 8, B10011100, B10100000, B10100000, B01111100, B00000000, // y
3, 8, B01100100, B01010100, B01001100, B00000000, B00000000, // z
3, 8, B00001000, B00110110, B01000001, B00000000, B00000000, // {
1, 8, B01111111, B00000000, B00000000, B00000000, B00000000, // |
3, 8, B01000001, B00110110, B00001000, B00000000, B00000000, // }
4, 8, B00001000, B00000100, B00001000, B00000100, B00000000, // ~
};
int DIN = 12;
int CLK = 10;
int CS = 11;
int maxInUse = 3;
MaxMatrix m(DIN, CS, CLK, maxInUse);
byte buffer[10];
char text[]= "Hello Eagler8 "; // 滚动文本
void setup() {
m.init(); // 模块初始化
m.setIntensity(8); // 点阵亮度 0-15
}
void loop() {
printStringWithShift(text, 100); // (文字,滚动速度)
}
// 显示=滚动提取的字符
void printCharWithShift(char c, int shift_speed) {
if (c < 32) return;
c -= 32;
memcpy_P(buffer, CH + 7 * c, 7);
m.writeSprite(32, 0, buffer);
m.setColumn(32 + buffer[0], 0);
for (int i = 0; i < buffer[0] + 1; i++){
delay(shift_speed);
m.shiftLeft(false, false);
}
}
// 从文本字符串中提取字符
void printStringWithShift(char* s, int shift_speed) {
while (*s != 0) {
printCharWithShift(*s, shift_speed);
s++;
}
}
6mm large size 8x8 LED square grid dot matrix module can be cascaded red, green, blue and white optional 8-level brightness
Project 32: Establish letter library, horizontal scrolling text display (three cascades)
Experimental scene pictures
Comparison of large and small dot matrix screens
6mm large size 8x8 LED square lattice module can be cascaded with red, green, blue and white optional 8-level brightness
Project 33: Dynamic Music Spectrum Analyzer
Experimental open source code
/*
【Arduino】168种传感器模块系列实验(资料代码+仿真编程+图形编程)
实验一百七十六:6mm大尺寸8x8LED方块方格点阵模块 可级联 红绿蓝白色 可选8级亮度
项目三十三:动态音乐频谱仪
接脚连线:
MAX7219 UNO
VCC →→→→→ 5V
GND →→→→→ GND
DIN →→→→→ D12(数据,数据接收引脚)
CS →→→→→ D11(负载,命令接收引脚)
CLK →→→→→ D10(时钟,时钟引脚)
*/
#include "LedControl.h"
/* Led matrix - Max7219 Declared */
LedControl lc = LedControl(12, 11, 10, 1);
const int maxScale = 11;
/* Sensor - Max9812 Declared */
const int sensorPin = A4;
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, 1); // 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(250);
}
}
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 graph
6mm large size 8x8 LED square lattice module can be cascaded with red, green, blue and white optional 8-level brightness
Project 33: Dynamic Music Spectrum Analyzer
Experimental video clip
https://v.youku.com/v_show/id_XNTgxMDQ2OTc2MA==.html?spm=a2hcb.playlsit.page.1
Project: Dynamic spectrum analyzer with dual dot matrix screen of FFT algorithm
Experimental video clip
https://v.youku.com/v_show/id_XNTgyMjEwNjcwMA==.html?spm=a2hcb.playlsit.page.1
Experimental scene dynamic diagram