单片机万年历 时钟 闹钟 温度程序.. 下载本文

a=~a; a+=1; f=1; } else f=0; b<<=4;

b+=(a&0xf0)>>4; return b; }

void display(void) //6 { uint o,p; o=temp/10; p=temp; write_com(0x80+0x40+13); if(f==1) write_date(0x2D); write_date(0x30+o); write_date(0x30+p); }*/

//主函数

//**************************************************************************************************************************************** void main() { init(); while(1) { 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); } write_com(0x80); write_date(0x30); while(w6!=0) { /*temp=readtemperature(); display();//显示温度*/ if(TR0==1) { write_sfr(6,yue); write_sfr(3,nian); write_sfr(1,nian2); write_sfr(9,ri); write_sfm(4,shi); write_sfm(7,fen); write_sfm(10,miao); if(w2==0) { write_com(0x80); write_date(0x20); write_com(0x0c); k=0; } if(k==1) { if(miao1==miao&&fen1==fen&&shi1==shi&&ri1==ri) {while(w2!=0) { L=0; }; k=0; } L=1; } } keyscan(); } while(!w6); 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); } while(w6!=0) { keyscan2(); k=1; } while(!w6); } }

//定时器控制程序,指定秒 分钟 小时的进位规则,和最大值 //****************************************************** void timer0() interrupt 1 { TH0=(65536-50000)/256; TL0=(65536-50000)%6; count++; if(count==18) { count=0; miao++; if(miao==60) { miao=0; fen++; if(fen==60) { fen=0;

shi++; if(shi==24) { r++; if(r==7) r=0; write_xq(r); shi=0; ri++;

//************************************************************************************* if(yue==2) //判断是否是二月 { if((nian2*10+nian)%4==0&&(nian2*10+nian)0!=0)//判断是否是闰年 { if(ri==30) { ri=1; yue++; if(yue==13) { yue=1; nian++; if(nian==100) { nian=0; nian2++; write_sfr(1,nian2); } write_sfr(3,nian); } write_sfr(6,yue); } } else if(ri==29) { ri=1; yue++; if(yue==13) { yue=1; nian++;