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

          新聞中心

          EEPW首頁 > 嵌入式系統(tǒng) > 設(shè)計應(yīng)用 > 51單片機(jī)程序——按鍵控制LED燈

          51單片機(jī)程序——按鍵控制LED燈

          作者: 時間:2016-11-23 來源:網(wǎng)絡(luò) 收藏
          #include
          void Delay(unsigned int t);
          sbit key=P3^2; //對應(yīng)單片機(jī)開發(fā)板上s19按鍵
          void main (void)
          {
          while (1) //函數(shù)開始后,一直在檢測按鍵是否被按下
          {
          if(key==0)
          {
          unsigned char i; //定義一個無符號字符型局部變量 i 取值范圍 0~255
          P0=0x7f; //賦初始值,右邊第一個燈亮起來
          for(i=0;i<8;i++) //加入 for循環(huán),表明for循環(huán)大括號中的程序循環(huán)執(zhí)行8次
          {
          Delay(50000);
          P0>>=1; //向右移動一位。
          P0=P0|0x80; //右移后,左端自動賦值0,所以需要該語句賦值1
          }
          }
          else
          {
          P0=0x00;
          }
          }
          }
          void Delay(unsigned int t)
          {
          while(--t);
          }



          關(guān)鍵詞: 51單片機(jī)按鍵控制LED

          評論


          技術(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); })();