目录
一、LED点阵屏介绍
二、显示原理
三、仿真演示
四、源程序
LED点阵屏发光亮度强,指示效果好,可以制作运动的发光图文,更容易吸引人的注意力,信息量大,随时更新,有着非常好的广告和告示效果。此处就LED点阵屏动态扫描显示作一个简单的介绍。1.LED点阵屏显示原理概述为一种8x8的LED点阵单色行共阳模块的内部等效电路图,对于红光LED其工作正向电压约为1.8v ,其持续工作的正向电流一般10ma左右,峰值电流可以更大。如下图,当某一行线为高电平而某一列线为低时,其行列交叉的点就被点亮,当某一行线为低电平时,无论列线如何,对应的这一行的点全部为暗。LED点阵屏显示就是通过一定的频率进行逐行扫描,数据端不断输入数据显示。LED点阵屏广泛应用于各种公共场合,如汽车报站器、广告屏以及公告牌等LED点阵屏分类按颜色:单色、双色、全彩,按像素:8*8、16*16等(大规模的LED点阵通常由很多个小点阵拼接而成)。
通过16*16LED点阵循环动态显示15帧图片,实现箭头飞过的动态显示。
#include "reg52.h"
#define MATRIX_Column_Front P0
#define MATRIX_Column_Back P1
#define MATRIX_Data_Front P2
#define MATRIX_Data_Back P3
unsigned char i = 0;
unsigned char count = 0;
unsigned char offset = 0;
//点阵显示画面,共有15帧
unsigned int code MatrixLED[] = {
0xfffe,0xfffe,0xfffe,0xfffe,0xfffe,0xfffe,0xfffe,0xfffe,
0xfffc,0xfffc,0xfffc,0xfffc,0xfffc,0xfffc,0xfffc,0xfffc,
0xfff8,0xfff8,0xfff8,0xfff8,0xfff8,0xfff8,0xfff8,0xfff8,
0xfff0,0xfff0,0xfff0,0xfff0,0xfff0,0xfff0,0xfff0,0xfff0,
0xffe0,0xffe0,0xffe0,0xffe0,0xffe0,0xffe0,0xffe0,0xffe0,
0xffc8,0xffc0,0xffc0,0xffc1,0xffc0,0xffc0,0xffc8,0xffc0,
0xffb8,0xff90,0xff80,0xff81,0xff83,0xff81,0xff80,0xffb8,
0xfffb,0xff71,0xff20,0xff01,0xff03,0xff07,0xff03,0xff01,
0xfbff,0x71ff,0x20ff,0x01ff,0x03ff,0x07ff,0x03ff,0x01ff,
0xf7ff,0xe3ff,0x41ff,0x03ff,0x07ff,0x0fff,0x07ff,0xf7ff,
0xefff,0xc7ff,0x83ff,0x07ff,0x0fff,0x1fff,0xefff,0xc7ff,
0xdfff,0x8fff,0x07ff,0x0fff,0x1fff,0xdfff,0x8fff,0x07ff,
0xbfff,0x1fff,0x0fff,0x1fff,0xbfff,0x1fff,0x0fff,0x1fff,
0x7fff,0x3fff,0x1fff,0x7fff,0x3fff,0x1fff,0x7fff,0x3fff,
0x7fff,0x7fff,0x7fff,0x7fff,0x7fff,0x7fff,0x7fff,0x7fff
};
//每帧画面LED组成位置序号
unsigned int code MatrixORD[] = {
0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,
0x0001,0x0002,0x0001,0x0002,0x0001,0x0002,0x0001,0x0002,
0x0001,0x0002,0x0004,0x0001,0x0002,0x0004,0x0001,0x0002,
0x0001,0x0002,0x0004,0x0008,0x0001,0x0002,0x0004,0x0008,
0x0001,0x0002,0x0004,0x0008,0x0010,0x0002,0x0004,0x0008,
0x0001,0x0002,0x0004,0x0008,0x0010,0x0020,0x0001,0x0002,
0x0001,0x0002,0x0004,0x0008,0x0010,0x0020,0x0040,0x0001,
0x0001,0x0002,0x0004,0x0008,0x0010,0x0020,0x0040,0x0080,
0x0100,0x0200,0x0400,0x0800,0x1000,0x2000,0x4000,0x8000,
0x0200,0x0400,0x0800,0x1000,0x2000,0x4000,0x8000,0x0200,
0x0400,0x0800,0x1000,0x2000,0x4000,0x8000,0x0400,0x0800,
0x0800,0x1000,0x2000,0x4000,0x8000,0x0800,0x1000,0x2000,
0x1000,0x2000,0x4000,0x8000,0x1000,0x2000,0x4000,0x8000,
0x2000,0x4000,0x8000,0x2000,0x4000,0x8000,0x2000,0x4000,
0x8000,0x8000,0x8000,0x8000,0x8000,0x8000,0x8000,0x8000,
};
//毫秒级延时,用于点阵动态显示
void delay_us(unsigned char t)
{
while(t--);
}
//点阵显示函数
void MatrixLED_ShowColumn(unsigned int Column,unsigned int Data)
{
MATRIX_Column_Front = (unsigned char)((Column >>8)&0xFF); //高8位:
MATRIX_Column_Back = Column&0xFF; //低8位:
MATRIX_Data_Front = (unsigned char)((Data >>8)&0xFF); //高8位:
MATRIX_Data_Back = Data&0xFF; //低8位:
delay_us(50);
}
void main()
{
while(1)
{
for(i=0;i<8;i++) //循环8次,显示8列数据
{
MatrixLED_ShowColumn(MatrixORD[i+offset], MatrixLED[i+offset]);
}
count++; //计次延时
if(count>50)
{
count=0;
offset+=8; //偏移+8,切换下一帧画面
if(offset>112)
{
offset=0; //15帧画面播放完,重新开始播放
}
}
}
}
基于51单片机的飞过的箭头仿真源文件及源程序百度网盘链接:链接:https://pan.baidu.com/s/1rIWxLJG-ELPN_njIYVJKDA 提取码:j3kf