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

          新聞中心

          EEPW首頁 > 嵌入式系統(tǒng) > 設(shè)計應(yīng)用 > 單片機(jī)精華之利用內(nèi)置定時器對外部按鍵進(jìn)行計數(shù)

          單片機(jī)精華之利用內(nèi)置定時器對外部按鍵進(jìn)行計數(shù)

          作者: 時間:2016-11-21 來源:網(wǎng)絡(luò) 收藏
          問題描述:

          前面焊好的板子,按鍵按下10次以后,點亮led

          本文引用地址:http://www.ex-cimer.com/article/201611/319250.htm

          上代碼:

          #include

          sbit led = P1^0;

          unsigned int counter = 0;

          void init(void)
          {
          led = 0;
          TMOD = 0x06; // counter and 8-bit auto-reload
          TH0 = 256 - 1;
          TL0 = 256 - 1;
          ET0 = 1;
          EA = 1;
          TR0 = 1;
          }

          void key_counter() interrupt 1
          {
          counter ++;
          if(counter >= 3)
          {
          led = 1;
          }
          if(counter >=6)
          {
          counter = 0;
          }

          }


          void main()
          {
          init();
          while(1);
          }

          注意此時外部脈沖輸入的界限是P3.4口



          評論


          技術(shù)專區(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); })();