
8*8 点阵模块由 MAX7219 驱动,MAX7219 是一种集成化的串行输入/输出显示驱动器, 只需要 3个 IO 口即可驱动 1 个点阵,点阵显示时无闪烁且支持级联,8*8 点阵模块通过 Max7219 驱动,Max7219 采用的是三线串行通信,当接收 Arduino 数据时通过芯片内部 8*8 位静态 RAM 储存数据,在通过 Max7219 来控制 8*8 点阵模块的每个引脚的高低电平,从而达到显示目的。

| 引脚名称 | 描述 |
|---|---|
| CLK | 时钟引脚 |
| CS | 锁存引脚 |
| DIN | 数据引脚 |
| VCC | VCC(电源输入正极) |
| GND | GND(电源输入负极 |
供电电压:3.3V / 5V
连接方式:2.54mm排针
安装方式:双螺丝固定

Arduino UNO 示例(适用于Mixly IDE、Arduino IDE):点击下载
#include <SPI.h>
#include <Adafruit_GFX.h>
#include <Max72xxPanel.h>
Max72xxPanel myMatrix = Max72xxPanel(9,1,1);
uint8_t LEDArray[8];
const uint8_t LedArray1[8] PROGMEM ={0x00,0x18,0x24,0x00,0x00,0xa5,0x42,0x00};
const uint8_t LedArray2[8] PROGMEM ={0x00,0x24,0x18,0x00,0x00,0x24,0xc3,0x00};
void setup(){
myMatrix.setRotation(0,3);
myMatrix.fillScreen(0);
myMatrix.write();
}
void loop(){
//MAX7219上显示笑脸和哭脸各1秒
memcpy_P(&LEDArray, &LedArray1, 8);
for(int index_i=0; index_i<8; index_i++)
{
for(int index_j=0*8; index_j<0*8+8; index_j++)
{
if((LEDArray[index_i]&0x01)>0)
myMatrix.drawPixel(index_j, 7-index_i,1);
else
myMatrix.drawPixel(index_j, 7-index_i,0);
LEDArray[index_i] = LEDArray[index_i]>>1;
}
}
myMatrix.write();
delay(1000);
memcpy_P(&LEDArray, &LedArray2, 8);
for(int index_i=0; index_i<8; index_i++)
{
for(int index_j=0*8; index_j<0*8+8; index_j++)
{
if((LEDArray[index_i]&0x01)>0)
myMatrix.drawPixel(index_j, 7-index_i,1);
else
myMatrix.drawPixel(index_j, 7-index_i,0);
LEDArray[index_i] = LEDArray[index_i]>>1;
}
}
myMatrix.write();
delay(1000);
}
ESP32 Python 示例:
import machine
import time
def write_byte(data):
CS.value(0)
for i in range(0, 8, 1):
CLK.value(0)
if ((data<<i)&0x80) == 0:
DIN.value(0)
else:
DIN.value(1)
CLK.value(1)
def write_data(addr, data):
CS.value(0)
write_byte(addr)
write_byte(data)
time.sleep_us(5)
CS.value(1)
def Picture_display(Picture):
for i in range(0, 8, 1):
write_data(i + 1, Picture[i])
CLK = machine.Pin(18, machine.Pin.OUT)
CS = machine.Pin(5, machine.Pin.OUT)
DIN = machine.Pin(23, machine.Pin.OUT)
smiley = [0x00, 0x42, 0xA5, 0x00, 0x00, 0x24, 0x18, 0x00]
Crying_face = [0x00, 0xC3, 0x24, 0x00, 0x00, 0x18, 0x24, 0x00]
while True:
Picture_display(smiley)
time.sleep(1)
Picture_display(Crying_face)
time.sleep(1)
示例程序(UNO开发板):点击下载

示例程序(ESP32开发板):点击下载

Arduino环境搭建
准备配件:
电路接线图:

Micropython环境搭建
准备配件:
电路接线图:




库文件:点击下载
视频教程:点击查看

器件连接好线之后,将上述程序烧录到 开发板之后,按下复位键,会看到点阵循环显示笑脸和哭脸。