#include<reg52.h>
#define uchar unsigned char
#define uint unsigned int
uchar code tab1[]="li jia 1";
uchar code tab2[]="li jia 2";
sbit lcden=P3^4;
sbit lcdrs=P3^5;
uchar num;
sbit dula=P2^6;
sbit wela=P2^7;
void delay(uint x)
{
uint i,j;
for(i=x;i>0;i--)
for(j=110;j>0;j--);
}
void write_com (uchar com)
{
lcdrs=0;
P0=com;
delay(5);
lcden=1;
delay(5);
lcden=0;
}
void write_date(uchar date)
{
lcdrs=1;
P0=date;
delay(5);
lcden=1;
delay(5);
lcden=0;
}
void init()
{
dula=0;
wela=0;
lcden=0;
write_com(0x38);
write_com(0x0c);
write_com(0x06);
write_com(0x01);
}
void main()
{
init();
write_com(0x80);
for(num=0;num<8;num++)
{
write_date(tab1[num]);
delay(20);
}
write_com(0x80+0x41);
for(num=0;num<8;num++)
{
write_date(tab2[num]);
delay(20);
}
while(1);
}
这个程序怎么不对了?显示不出来啊,而且按复位开关还会出现数码管亮了是怎么回事? |