#include<reg52.h>
#define uchar unsigned char
#define uint unsigned int
sbit lcden="P3"^4;
sbit lcdrs="P3"^5;
uchar table1[]="2009 08 19 Wed";
uchar table2[]="00:00:50";
uchar a="0",b=0,c;
uchar miao,shi,fen;
void write_com(uchar com)
{
lcdrs=0;
P0=com;
delay(5);
lcden=1;
delay(5);
lcden=0;
}
void write_dat(uchar dat)
{
lcdrs=1;
P0=dat;
delay(5);
lcden=1;
delay(5);
lcden=0;
}
void init()
{
lcden=0;
write_com(0x38);
write_com(0x0c);
write_com(0x06);
write_com(0x01);
write_com(0x81);
for(a=0;a<14;a++)
{
write_dat(table1[a]);
delay(5);
}
write_com(0x80+0x40+3);
for(b=0;b<8;b++)
{
write_dat(table2);
delay(5);
}
miao=50;
}
void display(uchar add,uchar shu)
{
uchar ge,shi;
ge=shu%10;
shi=shu/10;
write_com(0x80+0x40+add);
write_dat(shi+0x30);
write_com(0x80+0x40+add+1);
write_dat(ge+0x30);
}
void main()
{
init();
while(1);
}
delay(uchar a)
{
uint x,y;
for(x=a;x>0;x--)
for(y=110;y>0;y--);
}
文章评论(0条评论)
登录后参与讨论