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

          新聞中心

          EEPW首頁 > 嵌入式系統(tǒng) > 設(shè)計(jì)應(yīng)用 > 單片機(jī)驅(qū)動(dòng)4X4矩陣式鍵盤輸入程序

          單片機(jī)驅(qū)動(dòng)4X4矩陣式鍵盤輸入程序

          作者: 時(shí)間:2012-12-05 來源:網(wǎng)絡(luò) 收藏

          C語言源程序:

          #include AT89X51.H>
          unsigned char code table[]={0x3f,0x06,0x5b,0x4f,
          0x66,0x6d,0x7d,0x07,
          0x7f,0x6f,0x77,0x7c,
          0x39,0x5e,0x79,0x71};
          unsigned char temp;
          unsigned char key;
          unsigned char i,j;

          //我的程序沒有注釋,不過很簡單。有不懂的上論壇51版塊那解決http://www.51hei.com c程序和上面的匯編程序是實(shí)現(xiàn)一樣的功能的,初學(xué)者可通過對比熟悉兩種語言的使用方法。
          void main(void)
          {
          while(1)
          {
          P3=0xff;
          P3_4=0;
          temp=P3;
          temp=temp 0x0f;
          if (temp!=0x0f)
          {
          for(i=50;i>0;i--)
          for(j=200;j>0;j--);
          temp=P3;
          temp=temp 0x0f;
          if (temp!=0x0f)
          {
          temp=P3;
          temp=temp 0x0f;
          switch(temp)
          {
          case 0x0e:
          key=7;
          break;
          case 0x0d:
          key=8;
          break;
          case 0x0b:
          key=9;
          break;
          case 0x07:
          key=10;
          break;
          }
          temp=P3;
          P1_0=~P1_0;
          P0=table[key];
          temp=temp 0x0f;
          while(temp!=0x0f)
          {
          temp=P3;
          temp=temp 0x0f;
          }
          }
          }

          P3=0xff;
          P3_5=0;
          temp=P3;
          temp=temp 0x0f;
          if (temp!=0x0f)
          {
          for(i=50;i>0;i--)
          for(j=200;j>0;j--);
          temp=P3;
          temp=temp 0x0f;
          if (temp!=0x0f)
          {
          temp=P3;
          temp=temp 0x0f;
          switch(temp)
          {
          case 0x0e:
          key=4;
          break;
          case 0x0d:
          key=5;
          break;
          case 0x0b:
          key=6;
          break;
          case 0x07:
          key=11;
          break;
          }
          temp=P3;
          P1_0=~P1_0;
          P0=table[key];
          temp=temp 0x0f;
          while(temp!=0x0f)
          {
          temp=P3;
          temp=temp 0x0f;
          }
          }
          }

          P3=0xff;
          P3_6=0;
          temp=P3;
          temp=temp 0x0f;
          if (temp!=0x0f)
          {
          for(i=50;i>0;i--)
          for(j=200;j>0;j--);
          temp=P3;
          temp=temp 0x0f;
          if (temp!=0x0f)
          {
          temp=P3;
          temp=temp 0x0f;
          switch(temp)
          {
          case 0x0e:
          key=1;
          break;
          case 0x0d:
          key=2;
          break;
          case 0x0b:
          key=3;
          break;
          case 0x07:
          key=12;
          break;
          }
          temp=P3;
          P1_0=~P1_0;
          P0=table[key];
          temp=temp 0x0f;
          while(temp!=0x0f)
          {
          temp=P3;
          temp=temp 0x0f;
          }
          }
          }

          P3=0xff;
          P3_7=0;
          temp=P3;
          temp=temp 0x0f;
          if (temp!=0x0f)
          {
          for(i=50;i>0;i--)
          for(j=200;j>0;j--);
          temp=P3;
          temp=temp 0x0f;
          if (temp!=0x0f)
          {
          temp=P3;
          temp=temp 0x0f;
          switch(temp)
          {
          case 0x0e:
          key=0;
          break;
          case 0x0d:
          key=13;
          break;
          case 0x0b:
          key=14;
          break;
          case 0x07:
          key=15;
          break;
          }
          temp=P3;
          P1_0=~P1_0;
          P0=table[key];
          temp=temp 0x0f;
          while(temp!=0x0f)
          {
          temp=P3;
          temp=temp 0x0f;
          }
          }
          }
          }
          }

          蜂鳴器相關(guān)文章:蜂鳴器原理

          上一頁 1 2 下一頁

          評論


          相關(guān)推薦

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