微波EDA网,见证研发工程师的成长!
首页 > 硬件设计 > 嵌入式设计 > 单片机驱动16*16点阵LED汉字显示c51程序

单片机驱动16*16点阵LED汉字显示c51程序

时间:12-05 来源:互联网 点击:

//=========================================
//******* 单片机驱动16*16点阵LED汉字显示c51程序 *******
//******* 作者:http://www.51hei.com *******
//=========================================
//晶振12MHz
//P1.0~P1.3接74154行扫描
//P3.0、P3.1接74164串转并
#include reg51.h>
#define uchar unsigned char
#define uint unsigned int

uchar int_t;
uchar i;
uchar j;
uchar count=2; //2个字
uint k=0;

void t0_int() interrupt 1
{
TL0=0x18;
TH0=0x1C;
int_t++;
if(int_t==2) //移动速度2ms
{
int_t=0;
k=k+2;
if(k==count*32)
k=0;
}
}

void delay(uint dt)//2字节
{
uchar bt;//1字节
for (;dt;dt--)
{
for (bt=0;bt255;bt++);
}
}

void serial_send(uchar dat)
{
SCON=0x00;
SBUF=~dat;
while(1){ if(TI) {TI=0;break;} }
}

unsigned char code hzdot[64] = {
/*测 CB2E2 */
0x40,0x02,0x27,0xC2,0x24,0x42,0x84,0x52,0x45,0x52,0x55,0x52,0x15,0x52,0x25,0x52,
0x25,0x52,0x25,0x52,0xC5,0x52,0x41,0x02,0x42,0x82,0x42,0x42,0x44,0x4A,0x48,0x04,

/*试 CCAD4 */
0x00,0x20,0x40,0x28,0x20,0x24,0x30,0x24,0x27,0xFE,0x00,0x20,0xE0,0x20,0x27,0xE0,
0x21,0x20,0x21,0x10,0x21,0x10,0x21,0x0A,0x29,0xCA,0x36,0x06,0x20,0x02,0x00,0x00

};

void display()
{
j=k;
for(i=0;i16;i++)
{
P1=i;
serial_send(hzdot[j]);
j++;
serial_send(hzdot[j]);
j++;
if(j==count*32)
j=0;
delay(1);
}
}

void main()
{
SCON=0x00;
TMOD=0x01;
IE|=0x82;
TL0=0x18;
TH0=0x1C;
delay(100);
TR0=1; //启动T0定时器
for(;;)
display();
}

Copyright © 2017-2020 微波EDA网 版权所有

网站地图

Top