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

          新聞中心

          [C51代碼]4*4鍵盤掃描

          作者: 時(shí)間:2016-11-10 來源:網(wǎng)絡(luò) 收藏
          程序如下:
          #include
          #define uint unsigned int
          #define uchar unsigned char
          sbit key3 =P2^0; //按鍵的行檢測信號
          sbit key2 =P2^1;
          sbit key1 =P2^2;
          sbit key0 =P2^3;
          sbit dis0 =P2^4;
          sbit dis1 =P2^5;
          sbit dis2 =P2^6;
          sbit dis3 =P2^7;
          sbit dis4 =P3^3;
          uchar keyx,key;
          uchar code disp[17]={0x00,0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,
          0x7f,0x6f,0x77,0x7c,0x39,0x5e,0x79,0x71};
          void delay(uint i)
          {for(;i>0;i--)
          ;
          }
          uchar keyscan() //數(shù)碼管顯示掃描與鍵盤檢測
          {
          static dis=0;
          dis=(dis+1)%5;
          dis0=1;dis1=1;dis2=1;dis3=1;dis4=1;
          switch(dis) //位選碼輸出
          {
          case 0: dis0=0; break;
          case 1: dis1=0; break;
          case 2: dis2=0; break;
          case 3: dis3=0; break;
          case 4: dis4=0; break;
          }
          if(!key0) keyx=dis+1; //鍵盤的行檢測與譯碼
          if(!key1) keyx=dis+5;
          if(!key2) keyx=dis+9;
          if(!key3) keyx=dis+13;
          return keyx;
          }
          void main(void)
          { while(1)
          {
          key=keyscan();
          P0=disp[key];
          delay(3000);
          }
          }


          關(guān)鍵詞: C51代碼4*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); })();