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

          新聞中心

          EEPW首頁 > 嵌入式系統(tǒng) > 設計應用 > 用定時器實現(xiàn)的1602可調電子鐘

          用定時器實現(xiàn)的1602可調電子鐘

          作者: 時間:2016-11-29 來源:網(wǎng)絡 收藏
          本人最近小搞了下單片機,目前還是菜鳥,以下是單片機程序,基本功能都可以實現(xiàn),但程序有點小問題(反應不靈敏),還請高手指點下,感激不盡哦?。?!
          #include #define uchar unsigned char#define uint unsigned intuchar code table[]="   2011-3-11  ";uchar code table1[]="  14:59:55  ";uchar count, hour, minute, second, press;sbit rs=P2^4;sbit rw=P2^5;sbit en=P2^6;sbit key1=P3^0;sbit key2=P3^1;sbit key3=P3^2;void delay (){ ; ;}void write_cmd(uchar cmd)   //1602寫指令{rs=0;delay();rw=0;delay();en=0;delay();P0=cmd;en=1;delay();en=0;delay();}void write_byte(uchar date)  //1602寫數(shù)據(jù){rs=1;delay();rw=0;delay();en=0;delay();P0=date;en=1;delay();en=0;    }    void delay1(uint z){uint x, y;for(x=z;x>0;x--)for(y=110;y>0;y--);}void display(uchar addr, uchar date)  //顯示在液晶屏上{uchar ge, shi;ge=date%10;shi=date/10;write_cmd(0x80+0x40+addr);write_byte(shi+0x30);write_byte(ge+0x30);}void keyscan()  //鍵盤掃描,key1功能鍵,key2增加,key3減少{if(key1==0){delay1(5);if(key1==0){while(!key1);press++;if(press==1){TR0=0;write_cmd(0x80+0x40+0x09);write_cmd(0x0f);}if(press==2){write_cmd(0x80+0x40+0x06);write_cmd(0x0f);}if(press==3){write_cmd(0x80+0x40+0x03);write_cmd(0x0f);}if(press==4){press=0;write_cmd(0x0c);TR0=1;}}}if(key2==0){delay1(5);if(key2==0){while(!key2);if(press==1){second++;if(second==60){second=0;}display(8,second);}if(press==2){minute++;if(minute==60){minute=0;}display(5,minute);}if(press==3){hour++;if(hour==24){hour=0;}display(2,hour);}}}if(key3==0){delay1(5);if(key3==0){while(!key3);if(press==1){second--;if(second==-1){second=59;}display(8,second);}if(press==2){minute--;if(minute==-1){minute=59;}display(5,minute);}if(press==3){hour--;if(hour==0){hour=23;}display(2,hour);}}}}
          				
                      
                          
          			
          							
          上一頁 1 2 下一頁

          評論


          技術專區(qū)

          關閉
          看屁屁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); })();