用户工具

站点工具


侧边栏

索引

抱歉,您没有权限增加页面
传感器和模块:点阵模块8_8_16_16

1、 产品图片

2、产品购买地址

3、功能介绍

8*8点阵由64个发光二极管组成,按照传统的矩阵扫描方式,64个发光二极管至少需要16个IO口才能操作。于是我们引入了MAX7219驱动芯片,它通过16位数据串行输入输出方式完成控制64个LED,全程仅需3个IO口。

4、产品参数

  • 单个模块可以驱动一个8*8共阴点阵
  • 模块工作电压:5V
  • 模块尺寸:长5厘米X宽3.2厘米X高1.5厘米
  • 带4个固定螺丝孔,孔径3mm,可使用本店M3铜柱固定
  • 模块带输入输出接口,支持多个模块级联

5、级联使用方式

模块左边为输入端口,右边为输出端口。控制单个模块时,只需要将输入端口接到CPU。多个模块级联时,第1个模块的输入端接CPU,输出端接第2个模块的输入端,第2个模块的输出端接第3个模块的输入端,以此类推。

6、示例程序一

GND 接 GND DIN 接 pin5 CS 接 pin4 CLK 接pin3

//中贝斯特UltiRobot88点阵模块示例教程
//程序效果:依次显示0-9,A-Z,中、国字样。
//淘宝店地址:zhongbest.taobao.com
//专业Arduino资料网站:www.arduino365.com

int clk =3;
int cs=4;
int din=5;
unsigned char disp1[38][8]={
{0x3C,0x42,0x42,0x42,0x42,0x42,0x42,0x3C},//0
{0x10,0x18,0x14,0x10,0x10,0x10,0x10,0x10},//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
{0x8,0x14,0x22,0x3E,0x22,0x22,0x22,0x22},//A
{0x3C,0x22,0x22,0x3E,0x22,0x22,0x3C,0x0},//B
{0x3C,0x40,0x40,0x40,0x40,0x40,0x3C,0x0},//C
{0x7C,0x42,0x42,0x42,0x42,0x42,0x7C,0x0},//D
{0x7C,0x40,0x40,0x7C,0x40,0x40,0x40,0x7C},//E
{0x7C,0x40,0x40,0x7C,0x40,0x40,0x40,0x40},//F
{0x3C,0x40,0x40,0x40,0x40,0x44,0x44,0x3C},//G
{0x44,0x44,0x44,0x7C,0x44,0x44,0x44,0x44},//H
{0x7C,0x10,0x10,0x10,0x10,0x10,0x10,0x7C},//I
{0x3C,0x8,0x8,0x8,0x8,0x8,0x48,0x30},//J
{0x0,0x24,0x28,0x30,0x20,0x30,0x28,0x24},//K
{0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x7C},//L
{0x81,0xC3,0xA5,0x99,0x81,0x81,0x81,0x81},//M
{0x0,0x42,0x62,0x52,0x4A,0x46,0x42,0x0},//N
{0x3C,0x42,0x42,0x42,0x42,0x42,0x42,0x3C},//O
{0x3C,0x22,0x22,0x22,0x3C,0x20,0x20,0x20},//P
{0x1C,0x22,0x22,0x22,0x22,0x26,0x22,0x1D},//Q
{0x3C,0x22,0x22,0x22,0x3C,0x24,0x22,0x21},//R
{0x0,0x1E,0x20,0x20,0x3E,0x2,0x2,0x3C},//S
{0x0,0x3E,0x8,0x8,0x8,0x8,0x8,0x8},//T
{0x42,0x42,0x42,0x42,0x42,0x42,0x22,0x1C},//U
{0x42,0x42,0x42,0x42,0x42,0x42,0x24,0x18},//V
{0x0,0x49,0x49,0x49,0x49,0x2A,0x1C,0x0},//W
{0x0,0x41,0x22,0x14,0x8,0x14,0x22,0x41},//X
{0x41,0x22,0x14,0x8,0x8,0x8,0x8,0x8},//Y
{0x0,0x7F,0x2,0x4,0x8,0x10,0x20,0x7F},//Z
{0x8,0x7F,0x49,0x49,0x7F,0x8,0x8,0x8},//中
{0x7F,0x41,0x49,0x49,0x49,0x8,0x14,0x63},//国
};

void setup(){
  pinMode(cs,OUTPUT);
  pinMode(clk,OUTPUT);
  pinMode(din,OUTPUT);
  Init_MAX7219();
}
void loop(){
  char i,j;
//Write_Max7219(0x0f, 0x00); 
//Delay_xms(500);

  for(j=0;j<38;j++)
  {
   for(i=1;i<9;i++)
    Write_Max7219(i,disp1[j][i-1]);
   delay(500);
  } 

}

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); //扫描界限;8个数码管显示
Write_Max7219(0x0c, 0x01);  //掉电模式:0,普通模式:1
Write_Max7219(0x0f, 0x00);
delay(500); //显示测试:1;测试结束,正常显示:0
}

6、示例程序二

  • VCC接5V
  • GND接GND
  • DIN 接 D11 (MOSI)
  • CS 接 D10 (SS)
  • CLK 接 D13 (SCK)

//实验结果是实现一个动态的心跳,注意下接线于示例一不同

#include <SPI.h>

const byte sprite[2][8] = {
     { 0x00, 0x66, 0xFF, 0xFF, 0xFF, 0x7E, 0x3C, 0x18 }, 
     { 0x00, 0x00, 0x24, 0x7E, 0x7E, 0x3C, 0x18, 0x00 }    
};

const byte DECODEMODE = 0x09;
const byte INTENSITY = 0x0a;
const byte SCANLIMIT = 0x0b;
const byte SHUTDOWN = 0x0c;
const byte DISPLAYTEST = 0x0f;

void max7219(const byte reg, const byte data) {
   digitalWrite(SS, LOW);
   SPI.transfer(reg);
   SPI.transfer(data);
   digitalWrite(SS, HIGH); 
}

void setup() {
   SPI.begin();
  
   max7219(SCANLIMIT, 7);
   max7219(DECODEMODE, 0);
   max7219(INTENSITY, 2);
   max7219(DISPLAYTEST, 0);
   max7219(SHUTDOWN, 1); 
  
   for(byte i=0; i<8; i++) {
     max7219(i+1, 0);
   }
} 

void loop() {
   for(byte j=0; j<2; j++) {
     for(byte i=0; i<8; i++) {
       max7219(i+1, sprite[j][i]);
     }
   delay(500);
   }
}

7、示例程序三

由于市面上没有级联教程,所以就想起来写了个,按照类推方式应该可以组任意多个矩阵。

//中贝斯特UltiRobot88点阵模块示例教程
//程序效果:四个88点阵模块级联,组成一个1616模块,循环播放:中贝斯特
//淘宝店地址:zhongbest.taobao.com
//专业Arduino资料网站:www.arduino365.com
int clk =3;
int cs=4;
int din=5;
unsigned char disp3[4][8]={
{0x80,0x80,0x80,0x80,0xFC,0x84,0x84,0x84},//中
{0x00,0xF8,0x08,0x08,0x08,0x88,0x88,0x88},//贝
{0x00,0x02,0xBC,0x20,0x20,0x20,0x3E,0x24},//斯
{0x10,0x10,0x10,0xFE,0x10,0x10,0xFE,0x04},//特
};

unsigned char disp1[4][8]={
{0x84,0x84,0xFC,0x84,0x80,0x80,0x80,0x80},//中
{0x88,0x88,0x08,0x40,0x20,0x10,0x08,0x04},//贝
{0x24,0x24,0x24,0xA4,0x24,0x44,0xC4,0x84},//斯
{0x04,0xFE,0x04,0x44,0x24,0x04,0x14,0x08},//特
};

unsigned char disp4[4][8]={
{0x00,0x00,0x00,0x00,0x1F,0x10,0x10,0x10},//中
{0x00,0x0F,0x08,0x08,0x08,0x08,0x08,0x08},//贝
{0x11,0x11,0x3F,0x11,0x11,0x1F,0x11,0x11},//斯
{0x08,0x08,0x28,0x28,0x3E,0x28,0x49,0x08},//特
};

unsigned char disp2[4][8]={
{0x10,0x10,0x1F,0x10,0x00,0x00,0x00,0x00},//中
{0x08,0x08,0x09,0x01,0x02,0x04,0x08,0x10},//贝
{0x1F,0x11,0x11,0x7F,0x02,0x11,0x20,0x40},//斯
{0x0E,0x78,0x28,0x08,0x08,0x08,0x08,0x08},//特
};

void setup(){
  pinMode(cs,OUTPUT);
  pinMode(clk,OUTPUT);
  pinMode(din,OUTPUT);
  Init_MAX7219();
}
void loop(){
  char i,j;
//Write_Max7219(0x0f, 0x00); 
//Delay_xms(500);

  for(j=0;j<4;j++)
  {
   for(i=1;i<9;i++){
    Write_Max7219_1(i,disp1[j][i-1]);
    Write_Max7219_2(i,disp2[j][i-1]);
    Write_Max7219_3(i,disp3[j][i-1]);
    Write_Max7219_4(i,disp4[j][i-1]);}
   delay(500);
  } 

}

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_1(char address1,char dat1)
{ 
     digitalWrite(cs,0);
     Write_Max7219_byte(address1);           //写入地址,即数码管编号
     Write_Max7219_byte(dat1);               //写入数据,即数码管显示数字 
     digitalWrite(cs,1);                        
}

void Write_Max7219_2(char address2,char dat2)
{ 
     digitalWrite(cs,0);
     Write_Max7219_byte(address2);           //写入地址,即数码管编号
     Write_Max7219_byte(dat2);//写入数据,即数码管显示数字 
     digitalWrite(clk,1);
     Write_Max7219_byte(0x00);
     Write_Max7219_byte(0x00);
     digitalWrite(cs,1);

}

void Write_Max7219_3(char address3,char dat3)
{ 
     digitalWrite(cs,0);
     Write_Max7219_byte(address3);           //写入地址,即数码管编号
     Write_Max7219_byte(dat3);//写入数据,即数码管显示数字 
     digitalWrite(clk,1);
     Write_Max7219_byte(0x00);
     Write_Max7219_byte(0x00);
     Write_Max7219_byte(0x00);
     Write_Max7219_byte(0x00);
     digitalWrite(cs,1);

}

void Write_Max7219_4(char address4,char dat4)
{ 
     digitalWrite(cs,0);
     Write_Max7219_byte(address4);           //写入地址,即数码管编号
     Write_Max7219_byte(dat4);//写入数据,即数码管显示数字 
     digitalWrite(clk,1);
     Write_Max7219_byte(0x00);
     Write_Max7219_byte(0x00);
     Write_Max7219_byte(0x00);
     Write_Max7219_byte(0x00);
     Write_Max7219_byte(0x00);
     Write_Max7219_byte(0x00);
     digitalWrite(cs,1);

}


void Init_MAX7219(void)
{
Write_Max7219_1(0x09, 0x00);//译码方式:BCD码
Write_Max7219_1(0x0a, 0x01);//亮度 
Write_Max7219_1(0x0b, 0x07); //扫描界限;8个数码管显示
Write_Max7219_1(0x0c, 0x01);  //掉电模式:0,普通模式:1
Write_Max7219_1(0x0f, 0x00);

Write_Max7219_2(0x09, 0x00);//译码方式:BCD码
Write_Max7219_2(0x0a, 0x01);//亮度 
Write_Max7219_2(0x0b, 0x07); //扫描界限;8个数码管显示
Write_Max7219_2(0x0c, 0x01);  //掉电模式:0,普通模式:1
Write_Max7219_2(0x0f, 0x00);

Write_Max7219_3(0x09, 0x00);//译码方式:BCD码
Write_Max7219_3(0x0a, 0x01);//亮度 
Write_Max7219_3(0x0b, 0x07); //扫描界限;8个数码管显示
Write_Max7219_3(0x0c, 0x01);  //掉电模式:0,普通模式:1
Write_Max7219_3(0x0f, 0x00);

Write_Max7219_4(0x09, 0x00);//译码方式:BCD码
Write_Max7219_4(0x0a, 0x01);//亮度 
Write_Max7219_4(0x0b, 0x07); //扫描界限;8个数码管显示
Write_Max7219_4(0x0c, 0x01);  //掉电模式:0,普通模式:1
Write_Max7219_4(0x0f, 0x00);//显示测试:1;测试结束,正常显示:0
delay(500); 
}

8、视频演示

请移步我们的bilibili主页观看: 视频教程效果演示

9、相关资料下载

10、综合实验

传感器和模块/点阵模块8_8_16_16.txt · 最后更改: 2019/09/01 14:16 由 ultirobot