51单片机16X32LED点阵显示屏由单片机最小系统、行驱动电路74HC154、列驱运电路74HC595组成,实现汉字、数字的显示。电路简单。程序中以20个汉字作为显示示例。资料含51单片机C语言源程序、PROTEUS7.8仿真源文件。附送取模软件及取模说明文档,方便你自己更换显示内容。显示移动速度可在程序中进行设置。
#include
#define FOSC 12 //定义晶振频率
#define INIT_TH0 0x3C //定时器T0初始值
#define INIT_TL0 0xB0
#define TMOD_T00 0x00 //定义T0为方式0,GATE=0,C/T=0,13位计数器
#define TMOD_T01 0x01 //定义T0为方式1,GATE=0,C/T=0,16位计数器
#define TMOD_T02 0x02 //定义T0为方式2,GATE=0,C/T=0,自动装入8位计数器
#define TMOD_T03 0x03 //定义T0为方式3,GATE=0,C/T=0,定时器0分成两个8位计数器,定时器1停止计数
/*缩定定义*/
#define uchar unsigned char
#define uint unsigned int
/************位定义***************/
sbit STTP = P2^7;
/************函数声明*************/
void delay(uint c); //延时函数
void out_rxd(uchar *d); //汉字输出
/************汉字点阵*************/
char code hanzi[32][32]={
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, //显示空屏,如果只有一个字或将字全部移出必须设置一个空屏幕
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, //显示空屏,如果只有一个字或将字全部移出必须设置一个空屏幕
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
/*-- 文字: 基 --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/
0x00,0x88,0x20,0x88,0x20,0x91,0x20,0xA1,0xFF,0xC9,0x2A,0x89,0x2A,0x89,0x2A,0xBF,
0x2A,0x89,0x2A,0x89,0xFF,0xC9,0x20,0xA1,0x20,0x91,0x20,0x88,0x00,0x88,0x00,0x00,
/*-- 文字: 于 --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/
0x02,0x00,0x02,0x00,0x42,0x00,0x42,0x00,0x42,0x00,0x42,0x02,0x42,0x01,0x7F,0xFE,
0x42,0x00,0x42,0x00,0x42,0x00,0x42,0x00,0x42,0x00,0x02,0x00,0x02,0x00,0x00,0x00,
/*-- 文字: 5 --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=8x16 --*/
0x00,0x00,0x1F,0x98,0x10,0x84,0x11,0x04,0x11,0x04,0x10,0x88,0x10,0x70,0x00,0x00,
/*-- 文字: 1 --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=8x16 --*/
0x00,0x00,0x08,0x04,0x08,0x04,0x1F,0xFC,0x00,0x04,0x00,0x04,0x00,0x00,0x00,0x00,
/*-- 文字: 单 --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/
0x00,0x08,0x00,0x08,0x1F,0xC8,0x92,0x48,0x52,0x48,0x32,0x48,0x12,0x48,0x1F,0xFF,
0x12,0x48,0x32,0x48,0x52,0x48,0x92,0x48,0x1F,0xC8,0x00,0x08,0x00,0x08,0x00,0x00,
/*-- 文字: 片 --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/
0x00,0x00,0x00,0x01,0x00,0x06,0x7F,0xF8,0x04,0x40,0x04,0x40,0x04,0x40,0x04,0x40,
0x04,0x40,0xFC,0x40,0x04,0x7F,0x04,0x00,0x04,0x00,0x04,0x00,0x00,0x00,0x00,0x00,
/*-- 文字: 机 --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/
0x08,0x20,0x08,0xC0,0x0B,0x00,0xFF,0xFF,0x09,0x00,0x08,0xC1,0x00,0x06,0x7F,0xF8,
0x40,0x00,0x40,0x00,0x40,0x00,0x7F,0xFC,0x00,0x02,0x00,0x02,0x00,0x1E,0x00,0x00,
/*-- 文字: 的 --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/
0x00,0x00,0x1F,0xFE,0x30,0x84,0xD0,0x84,0x10,0x84,0x10,0x84,0x1F,0xFE,0x02,0x00,
0x0C,0x00,0xF1,0x00,0x10,0xC2,0x10,0x01,0x10,0x02,0x1F,0xFC,0x00,0x00,0x00,0x00,
/*-- 文字: 1 --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=8x16 --*/
0x00,0x00,0x08,0x04,0x08,0x04,0x1F,0xFC,0x00,0x04,0x00,0x04,0x00,0x00,0x00,0x00,
/*-- 文字: 6 --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=8x16 --*/
0x00,0x00,0x07,0xF0,0x08,0x88,0x11,0x04,0x11,0x04,0x18,0x88,0x00,0x70,0x00,0x00,
/*-- 文字: × --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x10,0x10,0x08,0x20,0x04,0x40,0x02,0x80,
0x01,0x00,0x02,0x80,0x04,0x40,0x08,0x20,0x10,0x10,0x00,0x00,0x00,0x00,0x00,0x00,
/*-- 文字: 3 --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=8x16 --*/
0x00,0x00,0x0C,0x18,0x10,0x04,0x11,0x04,0x11,0x04,0x12,0x88,0x0C,0x70,0x00,0x00,
/*-- 文字: 2 --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=8x16 --*/
0x00,0x00,0x0E,0x0C,0x10,0x14,0x10,0x24,0x10,0x44,0x11,0x84,0x0E,0x0C,0x00,0x00,
/*-- 文字: 点 --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/
0x00,0x01,0x00,0x02,0x03,0xEC,0x02,0x20,0x02,0x20,0x02,0x28,0xFE,0x26,0x12,0x20,
0x12,0x28,0x12,0x26,0x12,0x20,0x13,0xE0,0x10,0x08,0x10,0x07,0x00,0x00,0x00,0x00,
/*-- 文字: 阵 --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/
0x00,0x00,0x7F,0xFF,0x40,0x10,0x44,0x08,0x5B,0x10,0x60,0xE0,0x10,0x10,0x13,0x10,
0x1D,0x10,0xF1,0x10,0x17,0xFF,0x11,0x10,0x11,0x10,0x11,0x10,0x10,0x10,0x00,0x00,
/*-- 文字: 显 --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/
0x00,0x02,0x00,0x42,0x00,0x22,0x7F,0x1A,0x49,0x02,0x49,0xFE,0x49,0x02,0x49,0x02,
0x49,0x02,0x49,0xFE,0x49,0x02,0x7F,0x0A,0x00,0x12,0x00,0x62,0x00,0x02,0x00,0x00,
/*-- 文字: 示 --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/
0x02,0x04,0x02,0x08,0x42,0x10,0x42,0x60,0x42,0x00,0x42,0x02,0x42,0x01,0x43,0xFE,
0x42,0x00,0x42,0x00,0x42,0x00,0x42,0x40,0x42,0x20,0x02,0x10,0x02,0x0C,0x00,0x00,
/*-- 文字: 屏 --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/
0x00,0x02,0x00,0x0C,0x7F,0xF0,0x48,0x20,0x49,0x21,0x4D,0x26,0x4B,0xF8,0x49,0x20,
0x49,0x20,0x49,0x20,0x4B,0xFF,0x4D,0x20,0x79,0x20,0x00,0x20,0x00,0x00,0x00,0x00,
/*-- 文字: 程 --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/
0x24,0x10,0x24,0x60,0x25,0x80,0x7F,0xFF,0xC4,0x80,0x44,0x60,0x00,0x02,0x7C,0x92,
0x44,0x92,0x44,0x92,0x44,0xFE,0x44,0x92,0x44,0x92,0x7C,0x92,0x00,0x82,0x00,0x00,
/*-- 文字: 序 --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/
0x00,0x02,0x00,0x0C,0x3F,0xF0,0x20,0x00,0x20,0x80,0x20,0x80,0x28,0x80,0xA8,0x82,
0x6A,0x81,0x29,0xFE,0x2A,0x80,0x2C,0x80,0x28,0x80,0x20,0xA0,0x20,0xC0,0x00,0x00,
/*-- 文字: 设 --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/
0x02,0x00,0x02,0x00,0x42,0x00,0x33,0xFC,0x00,0x09,0x02,0x11,0x05,0x02,0x79,0xC2,
0x41,0x34,0x41,0x08,0x41,0x14,0x79,0x62,0x05,0x82,0x04,0x01,0x04,0x01,0x00,0x00,
/*-- 文字: 计 --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/
0x02,0x00,0x02,0x00,0x42,0x00,0x33,0xFE,0x00,0x04,0x02,0x08,0x02,0x00,0x02,0x00,
0x02,0x00,0xFF,0xFF,0x02,0x00,0x02,0x00,0x02,0x00,0x02,0x00,0x02,0x00,0x00,0x00,
/*-- 文字: 与 --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/
0x00,0x10,0x00,0x10,0x07,0x10,0xF9,0x10,0x11,0x10,0x11,0x10,0x11,0x10,0x11,0x10,
0x11,0x10,0x11,0x12,0x11,0x01,0x11,0x02,0x11,0xFC,0x10,0x00,0x00,0x00,0x00,0x00,
/*-- 文字: 仿 --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/
0x00,0x80,0x01,0x00,0x06,0x00,0x1F,0xFF,0xE0,0x01,0x10,0x02,0x10,0x0C,0x1F,0xF0,
0x91,0x00,0x71,0x02,0x11,0x01,0x11,0x02,0x11,0xFC,0x10,0x00,0x10,0x00,0x00,0x00,
/*-- 文字: 真 --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/
0x00,0x08,0x20,0x08,0x20,0x09,0x2F,0xFA,0x2A,0xAC,0x2A,0xA8,0x2A,0xA8,0xFA,0xA8,
0x2A,0xA8,0x2A,0xA8,0x2A,0xAC,0x2F,0xFA,0x20,0x09,0x20,0x08,0x00,0x08,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, //显示空屏,如果只有一个字或将字全部移出必须设置一个空屏幕
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
};
/************主函数***************/
void main()
{
uchar i,j,k; //i:每个字的显示循环;j每个字的显示码除以2;k每列刷新次数
uint b=0; //显示偏移控制,char类型最多只能显示14个汉字+一个空白位字符
uchar a; //控制移动间隔时间
SCON = 0x00;
while(1)
{
j=0;
if(a>6) //移动间隔时间;取值0-20
{
a=0;
b+=2;
if(b>=700) //显示到最后一个字,回头显示,判断值=字数*32
{
b=0;
}
}
for(i=0;i<16;i++)
{
P1=i;
for(k=0;k<1;k++)
{
STTP = 0;
out_rxd(&hanzi[3][j+b+1]);
out_rxd(&hanzi[3][j+b]);
out_rxd(&hanzi[2][j+b+1]);
out_rxd(&hanzi[2][j+b]);
out_rxd(&hanzi[1][j+b+1]);
out_rxd(&hanzi[1][j+b]);
out_rxd(&hanzi[0][j+b+1]);
out_rxd(&hanzi[0][j+b]);
STTP = 1;
delay(15);
}
j=j+2;
}
a++;
}
}
/************子函数**************/
void delay(uint c)
{
int i,j;
for(i=0;i
;
.......................................................................
上一篇:单片机电梯控制器代码
下一篇:分享一下stc15单片机的PWM波程序
推荐阅读最新更新时间:2024-11-12 02:12