<meter id="pryje"><nav id="pryje"><delect id="pryje"></delect></nav></meter>
          <label id="pryje"></label>

          新聞中心

          EEPW首頁(yè) > 嵌入式系統(tǒng) > 設(shè)計(jì)應(yīng)用 > STC單片機(jī)做的電子表C51程序

          STC單片機(jī)做的電子表C51程序

          作者: 時(shí)間:2012-08-29 來(lái)源:網(wǎng)絡(luò) 收藏

          電路很簡(jiǎn)單我就不畫(huà)了,是stc系列的單片機(jī)做的,顯示部分就是2個(gè)74hc573芯片連到P1口,然后用p3.0控制段選,按鍵的定義程序里有說(shuō)明。很容易就能搭出來(lái),下圖是效果圖,自己用萬(wàn)用板焊的,技術(shù)不行。到處都是飛線呵呵,請(qǐng)大家多多指教
          點(diǎn)擊瀏覽下一頁(yè)
          程序的c51語(yǔ)言完整版本的下載地址:http://www.51hei.com/f/biaoc4.rar

          #includestc90.h>#define uchar unsigned char#define uint unsigned intuchar d0,ss,gs,sf,gf,sm,gm;uchar e1,e2,e3,e4,e5,e6;uchar s1,q1;uchar shi,fen,miao;// 8 4 2 1 8 4 2 1  // h g f e d c b a//效正 累加數(shù)98 跑1320秒 實(shí)際1316//當(dāng)前已走秒數(shù) 乘以 當(dāng)前累加數(shù) 除以除以實(shí)際秒數(shù) 等于 累加數(shù)應(yīng)得值uchar code num[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f,0x80};//0-9 點(diǎn)uchar code wes[]={0x7f,0xbf,0xdf,0xef,0xf7,0xfb,0xfd,0x7f};//1-8位sbit dua=P3^0;sbit laba=P3^1;sbit a1=P3^2;//時(shí)間設(shè)置sbit a2=P3^3;//鬧鐘設(shè)置sbit a3=P3^4;//按鍵+sbit a4=P3^5;//按鍵-sbit a5=P3^7;//返回 啟動(dòng)鬧鐘void weiduan(uchar z,uchar x); //位段 函數(shù)void chushi();    //初始化函數(shù)void shijian();   //時(shí)間顯示函數(shù)void shjianbata();//測(cè)試時(shí)間函數(shù)void shezhi();    //時(shí)間設(shè)置函數(shù)void naozhong();  //鬧鐘這是函數(shù)void shu();       //時(shí)間最大值限制函數(shù)void delay(uchar d1);//延時(shí)函數(shù)//...................................................................void main(){ chushi(); //初始化時(shí)間TH0=(65535-40000)/256;//定時(shí)器裝初值TL0=(65535-40000)%256;ET0=1;//開(kāi)定時(shí)器0中斷TR0=1;//啟動(dòng)定時(shí)器0EA=1; //打開(kāi)總中斷l(xiāng)aba=1;while(1){  shijian(); //調(diào)用時(shí)間顯示函數(shù) 顯示時(shí)間 if(a1==1){if(a2==1){if(a3==1){if(a4==1)
          { weiduan(1,10);delay(5);weiduan(3,10);delay(5);weiduan(5,10);delay(5); }}}}if(a1==0){delay(100);if(a1==0){shezhi();}}if(a2==0){delay(100);if(a2==0){naozhong();}}//調(diào)用鬧鐘設(shè)置函數(shù)if(a5==0){delay(100);{if(a5==0){while(1)
          {if(q1==0){q1=1;break;}else{q1=0;break;}}while(a5==0);delay(100);}}}if(a2==0){delay(100);if(a2==0){naozhong();}    }if(q1==1){weiduan(6,0);delay(20);if(fen==e2)
          {if(shi==e1){laba=0;}}if(fen!=e2){laba=1;}  }else{laba=1;}}}//...................................................................void naozhong(){while(1){   ss=e1/10;gs=e1%10;  sf=e2/10;gf=e2%10;   sm=e3/10;gm=e3%10;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);if(a1==0){delay(100);if(a1==0){while(a1==0);delay(20);break;}}if(a2==0){delay(100);while(a2==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){e1++;}while(a3==0);delay(100);}if(a4==0){delay(20);if(a4==0){e1--;}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){e2++;}while(a3==0);delay(100);}if(a4==0){delay(20);if(a4==0){e2--;}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){e3++;}while(a3==0);delay(100);}if(a4==0){delay(20);if(a4==0){e3--;}while(a4==0);delay(100);}}}}//.........................................................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;}//.............................................................


          關(guān)鍵詞: STC單片 電子表 C51程序

          評(píng)論


          相關(guān)推薦

          技術(shù)專(zhuān)區(qū)

          關(guān)閉
          看屁屁www成人影院,亚洲人妻成人图片,亚洲精品成人午夜在线,日韩在线 欧美成人 (function(){ var bp = document.createElement('script'); var curProtocol = window.location.protocol.split(':')[0]; if (curProtocol === 'https') { bp.src = 'https://zz.bdstatic.com/linksubmit/push.js'; } else { bp.src = 'http://push.zhanzhang.baidu.com/push.js'; } var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(bp, s); })();