stc電子表c51程序V2.0 作者: 時(shí)間:2016-11-29 來(lái)源:網(wǎng)絡(luò) 加入技術(shù)交流群 掃碼加入和技術(shù)大咖面對(duì)面交流海量資料庫(kù)查詢(xún) 收藏 //.....................................................................................void shezhi()//時(shí)間設(shè)置函數(shù){while(1){ ss=shi/10;gs=shi%10; sf=fen/10;gf=fen%10; sm=miao/10;gm=miao%10;shijian();if(a2==0){delay(100);if(a2==0){while(a2==0);delay(20);break;}}if(a1==0){delay(100);while(a1==0);delay(20);s1++;}if(s1==3){s1=0;}if(s1==1){weiduan(0,10);delay(5);weiduan(1,10);delay(5);if(a3==0){delay(20);if(a3==0){shi++;}while(a3==0);delay(100);}if(a4==0){delay(20);if(a4==0){shi--;}while(a4==0);delay(100);}}if(s1==2){weiduan(2,10);delay(5);weiduan(3,10);delay(5);if(a3==0){delay(20);if(a3==0){fen++;}while(a3==0);delay(100);}if(a4==0){delay(20);if(a4==0){fen--;}while(a4==0);delay(100);}}if(s1==0){weiduan(4,10);delay(5);weiduan(5,10);delay(5);if(a3==0){delay(20);if(a3==0){miao++;}while(a3==0);delay(100);}if(a4==0){delay(20);if(a4==0){miao--;}while(a4==0);delay(100);}}}}//.....................................................................................void zhongduan() interrupt 1 //定時(shí)器中斷函數(shù)體{ TH0=(65535-40400)/256;TL0=(65535-40400)%256;if(e3>=60)//判斷秒等于或超過(guò)60{e2++; //分鐘加1e3=0;} //秒數(shù)清零if(e2>=60) //判斷分鐘等于或超過(guò)60{e1++; //小時(shí)加1e2=0;} //分鐘數(shù)清零if(e1>=24) //判斷小時(shí)等于或大于24{e1=0;} //小時(shí)數(shù) 清零d0++;//累加數(shù)shu(); //調(diào)用時(shí)間最大值限制函數(shù)} //.....................................................................................void delay(uchar d1)//延時(shí)函數(shù){uchar t0,t1;for(t0=d1;t0>0;t0--)for(t1=110;t1>0;t1--);}//.....................................................................................void weiduan(uchar z,uchar x) //位段選擇函數(shù){ P1=num[x];dua=1;dua=0;P1=wes[z];}//.....................................................................................void shijian()//動(dòng)態(tài)掃描時(shí)間顯示函數(shù) 帶延時(shí){chushi();//調(diào)用時(shí)間初始化函數(shù) delay(10);weiduan(0,ss);delay(10);weiduan(1,gs);delay(10);weiduan(2,sf);delay(10); weiduan(3,gf);delay(10);weiduan(4,sm);delay(10);weiduan(5,gm);delay(10);}//.....................................................................................void shu() //時(shí)間最大限制函數(shù)體{ if(d0>=98) //判斷定時(shí)器進(jìn)入 多少次{d0=0; //清除累加數(shù)miao++;} //秒數(shù)自+if(miao>=60)//判斷秒等于或超過(guò)60{fen++; //分鐘加1miao=0;} //秒數(shù)清零if(fen>=60) //判斷分鐘等于或超過(guò)60{shi++; //小時(shí)加1fen=0;} //分鐘數(shù)清零if(shi>=24) //判斷小時(shí)等于或大于24{shi=0;} //小時(shí)數(shù) 清零}//.....................................................................................void chushi() //時(shí)間初始化{ ss=shi/10;gs=shi%10; sf=fen/10;gf=fen%10; sm=miao/10;gm=miao%10;}//..................................................................................... 上一頁(yè) 1 2 下一頁(yè)
評(píng)論