|
#include
//#include
#define uint unsigned int
#define uchar unsigned char
void write_date(uchar date);
char shi,fen,miao;
uchar num1,num2,num3;
sbit dula=P2^6;
sbit wela=P2^7;
sbit keyg=P3^0;
sbit keyp=P3^1;
sbit keym=P3^2;
sbit FM=P2^3;
sbit lcden=P3^4;
sbit lcdrs=P3^5;
sbit rd=P3^7;
sbit rw=P3^6;
uchar code table[]=" 2014-08-06 WEN";
void delayms(uint ms)
{
uint j;
for(;ms>0;ms--)
for(j=110;j>0;j--);
}
void write_com(uchar com)
{
lcdrs=0;
P0=com;
delayms(5);
lcden=1;
delayms(5);
lcden=0;
}
void write_date(uchar date)
{
lcdrs=1;
P0=date;
delayms(5);
lcden=1;
delayms(5);
lcden=0;
}
void cof(uchar add,uchar date)
{
uchar shi,ge;
shi=date/10;
ge=date%10;
write_com(0x80+0x40+add);
write_date(0x30+shi);
write_date(0x30+ge);
}
void main()
{
uchar num;
rw=0;
shi=0;
fen=0;
miao=0;
lcden=0;
rd=0;
dula=0;
wela=0;
write_com(0x38);
write_com(0x0c);
write_com(0x06);
write_com(0x01);
write_com(0x80);
for(num=0;num<15;num++)
{
write_date(table[num]);
delayms(5);
}
write_com(0x80+0x40+6);
write_date(':');
delayms(5);
write_com(0x80+0x40+9);
write_date(':');
delayms(5);
cof(4,shi);
cof(7,fen);
cof(10,miao);
} |
|