#include
#define uchar unsigned char
#define uint unsigned int
sbit rs=P3^0;
sbit lcden=P3^1;
sbit s1=P3^6;
sbit s2=P3^7;
uchar count,shi,fen,miao,num;
uchar code table[]="2011-02-25";
uchar code table1[]="00:00:00";
void reflesh(uchar add,uchar date);
void delay(uchar z)
{
uint x,y;
for(x=0;x
for(y=0;y<110;y++);
}
void write_ins(uchar add)
{
rs=0;
delay(5);
P1=add;
lcden=1;
delay(5);
lcden=0;
delay(5);
}
void write_date(uchar add)
{
rs=1;
delay(5);
P1=add;
lcden=1;
delay(5);
lcden=0;
delay(5);
}
void init()
{
uchar i;
lcden=0;
shi=0;
fen=0;
miao=0;
write_ins(0x38);
write_ins(0x0c);
write_ins(0x06);
write_ins(0x01);
write_ins(0x80);
for(i=0;i<14;i++)
{
write_date(table[i]);
delay(5);
}
write_ins(0x80+0x40);
for(i=0;i<13;i++)
{
write_date(table1[i]);
delay(5);
}
TMOD=0x01;
TH0=(65536-50000)/256;
TL0=(65536-50000)%6;
EA=1;
ET0=1;
TR0=1;
}
void keyscan()
{
本文引用地址:
//m.amcfsurvey.com/article/201611/321662.htm
if(num==""||num==0)
{
if(s1==0)
delay(5);
if(s1==0)
{
while(!s1);
TR0=0;
write_ins(0x80+0x40+11);
write_ins(0x0c);
num=1;
}
}
if(num==1)
{
if(s1==0)
delay(5);
if(s1==0)
{
while(!s1);
write_ins(0x80+0x40+8);
write_ins(0x0c);
num=2;
}
}
if(num==2)
{
if(s1==0)
delay(5);
if(s1==0)
{
while(!s1);
write_ins(0x80+0x40+5);
write_ins(0x0c);
num=3;
}
}
if(num==3)
{
if(s1==0)
delay(5);
if(s1==0)
{
while(!s1);
write_ins(0x0c);
TR0=1;
num=0;
}
}
if(num!=0)
{
if(num==1)
{
if(s2==0)
delay(5);
if(s2==0)
{
while(!s2);
miao++;
if(miao==60)
miao=0;