-------------
{ rs=0; lcden=0; P0=com; delay(5); lcden=1; delay(5); lcden=0; }
void write_date(uchar date)//1602写数据函数 { rs=1; lcden=0; P0=date; delay(5); lcden=1; delay(5); lcden=0; }
void init()//初始函数 { uchar num; dula=0; wela=0; lcden=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]); delay(5); } write_com(0x80+0x40); for(num=0;num<12;num++) { write_date(table1[num]); delay(5); } TMOD=0x01;//选用定时器1的方式0
-------------
-------------
TH0=(65536-50000)/256; TL0=(65536-50000)%6; // TH1=243; // TL1=243; EA=1; ET0=1; TR0=1; // ET1=1; // TR1=1; }
void write_sfm(uchar add,uchar date)//液晶写时分秒函数 { uchar shi,ge; shi=date/10; ge=date; write_com(0x80+0x40+add); write_date(0x30+shi); write_date(0x30+ge); }
void keyscan()//键盘检测函数 { rd=0; if(s1==0) { delay(5); if(s1==0) { s1num++; while(!s1); if(s1num==1) { TR0=0; write_com(0x80+0x40+10); write_com(0x0f); } } if(s1num==2) { write_com(0x80+0x40+7); } if(s1num==3) { write_com(0x80+0x40+4);
-------------
-------------
}
if(s1num==4) { write_sfm(10,cmiao); write_sfm(7,cfen); write_sfm(4,cshi); write_com(0x80+0x40+10); }
if(s1num==5) { write_com(0x80+0x40+7); }
if(s1num==6) { write_com(0x80+0x40+4); }
if(s1num==7) { s1num=0; write_com(0x0c); write_sfm(10,miao); write_sfm(7,fen); write_sfm(4,shi); TR0=1; }
}
if(s1num!=0) { if(s2==0) { delay(5); if(s2==0) { while(!s2); if(s1num==1) { miao++; if(miao==60) miao=0; write_sfm(10,miao); write_com(0x80+0x40+10);
-------------
-------------
}
if(s1num==2) { fen++; if(fen==60) fen=0; write_sfm(7,fen); write_com(0x80+0x40+7); -------------
}
if(s1num==3) { shi++; if(shi==24) shi=0; write_sfm(4,shi); write_com(0x80+0x40+4); }
if(s1num==4) { cmiao++; if(cmiao==60) cmiao=0; write_sfm(10,cmiao); write_com(0x80+0x40+10); }
if(s1num==5) { cfen++; if(cfen==60) cfen=0; write_sfm(7,cfen); write_com(0x80+0x40+7); }
if(s1num==6) { cshi++; if(cshi==24) cshi=0; write_sfm(4,cshi); write_com(0x80+0x40+4); }
}
}
-------------
-------------
if(s3==0) { delay(5); if(s3==0) { while(!s3); if(s1num==1) { /* if(miao==0) { miao=59; write_sfm(10,miao); write_com(0x80+0x40+10); }*/ miao--; if(miao==-1) miao=59; write_sfm(10,miao); write_com(0x80+0x40+10); } if(s1num==2) { fen--; if(fen==-1) fen=59; write_sfm(7,fen); write_com(0x80+0x40+7); } if(s1num==3) { shi--; if(shi==-1) shi=23; write_sfm(4,shi); write_com(0x80+0x40+4); } if(s1num==4) { cmiao--; if(cmiao==-1) cmiao=59; write_sfm(10,cmiao); write_com(0x80+0x40+10); }