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

          新聞中心

          EEPW首頁 > 嵌入式系統(tǒng) > 設(shè)計(jì)應(yīng)用 > 一個(gè)改進(jìn)型的4*4矩陣鍵盤掃描

          一個(gè)改進(jìn)型的4*4矩陣鍵盤掃描

          作者: 時(shí)間:2016-11-30 來源:網(wǎng)絡(luò) 收藏
          #include
          #define uchar unsigned char
          #define uint unsigned int
          uchar temp,num,bai,shi,ge;
          uchar key[]={0x3f,0x5f,0x6f};
          uchar code table[]=
          {
          0x3f , 0x06 , 0x5b ,
          0x4f , 0x66 , 0x6d ,
          0x7d , 0x07 , 0x7f ,
          0x6f };
          void keyscan();
          void delay(uchar z);
          void dsp(uchar bai,uchar shi,uchar ge);
          void main()
          {
          while(1)
          {
          keyscan();
          dsp(bai,shi,ge);
          }
          }
          void delay(uchar z)
          {
          uchar x,y;
          for(x=100;x--;x>0)
          for(y=z;y--;y>0);
          }
          void dsp(uchar bai,uchar shi,uchar ge)
          {

          bai=num/100;
          shi=num%100/10;
          ge=num%10;

          P0=0xfb;
          P2=table[bai];
          delay(1);
          P0=0xfd;
          P2=table[shi];
          delay(1);
          P0=0xfe;
          P2=table[ge];
          delay(1);
          }
          void keyscan()
          { uchar i;
          for(i=0;i<3;i++)
          {
          P1=key[i];
          temp=P1;
          temp&=0x0f;
          if(temp!=0x0f) //如果有鍵按下
          {
          delay(5);
          temp=P1;
          temp&=0x0f;
          if(temp!=0x0f)//確實(shí)有鍵按下
          {
          switch(temp)
          {
          case 0x07:adclass=0&app_id=0&c=news&cf=1001&ch=0&di=128&fv=17&is_app=0&jk=f1c2511670cd2325&k=switch&k0=switch&kdi0=0&luki=1&n=10&p=baidu&q=98059059_cpr&rb=0&rs=1&seller_id=1&sid=2523cd701651c2f1&ssp2=1&stid=0&t=tpclicked3_hc&tu=u1831118&u=http%3A%2F%2Fwww%2E51hei%2Ecom%2Fmcu%2F2002%2Ehtml&urlid=0" id="1_nwl" mpid="1" target="_blank">switch(i)
          {
          case 0:num=1;break;
          case 1:num=5;break;
          case 2:num=9;break;
          };

          break;

          case 0x0b:switch(i)
          {
          case 0:num=2;break;
          case 1:num=6;break;
          case 2:num=10;break;
          };
          break;

          case 0x0d:switch(i)
          {
          case 0:num=3;break;
          case 1:num=7;break;
          case 2:num=11;break;
          };
          break;

          case 0x0e:switch(i)
          {
          case 0:num=4;break;
          case 1:num=8;break;
          case 2:num=12;break;
          };;
          break;

          while(temp!=0xf0) //松開手后就跳出循環(huán),否則等待松手
          {
          temp=P1;
          temp=temp&0xf0;
          dsp(bai,shi,ge);
          }
          }

          }
          }
          }
          }


          評(píng)論


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