51单片机3X4键盘扫描C程序_文芳菲_百度空间

#include<reg51.h>
#include<intrins.h>
int keyscan();
void delay();

void main()
{ while(1)
   P0=keyscan();
}
int keyscan()
{ int j=0;
   P3=0x00;
   P1=0xff;
    if(P1!=0xef)
     {
       delay();
       if(P1!=0xef)
         {
          P3=0xfb;
             do{ j++;
                 switch(P1)
                 {    case 0xaf:
                            switch(j)
                            {case 0x01:return 2;break;
                             case 0x02:return 5;break;
                             case 0x03:return 8;break;
                             case 0x04:return 11;break;
                             }
                             break;
                      case 0x6f:
                             switch(j)
                            {case 0x01:return 3;break;
                             case 0x02:return 6;break;
                             case 0x03:return 9;break;
                             case 0x04:return 12;break;
                             }
                             break;
                      case 0xcf:
                            switch(j)
                            {case 0x01:return 1;break;
                             case 0x02:return 4;break;
                             case 0x03:return 7;break;
                             case 0x04:return 10;break;
                             }
                             break;
                      case 0xef: break;
                   }
                   P3=_crol_(P3,1);
                  } while(P3!=0xbf);
               }
           }
     }
void delay()
{int i,j;
for(i=200;i>0;i--)
for(j=50;j>0;j--);
}



郑重声明:资讯 【51单片机3X4键盘扫描C程序_文芳菲_百度空间】由 发布,版权归原作者及其所在单位,其原创性以及文中陈述文字和内容未经(企业库qiyeku.com)证实,请读者仅作参考,并请自行核实相关内容。若本文有侵犯到您的版权, 请你提供相关证明及申请并与我们联系(qiyeku # qq.com)或【在线投诉】,我们审核后将会尽快处理。
—— 相关资讯 ——