⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 jianpan.c

📁 键盘扫描的一种方法经过调试可以运行!键盘扫描的一种方法经过调试可以运行
💻 C
字号:
#include <reg51.h>
#define uchar unsigned char
#define uint  unsigned int
 
void delay (void);
uchar keyscan(void);

void main(void)
{  uchar key ;
   
   P2=0x00;
 /* while(1)
  { 
    key=keyscan();
    delay();
    P2=key;
  }*/
}

void delay (void)
{ uint i;
  for(i=0;i<=200;i++)
  {}
}

uchar keyscan(void)
{  uchar sccode;     //行
   uchar recode;     //列 
   P1=0xf0;
   if((P1&0xf0)!=0xf0)
   { delay();
     if((P1&0xf0)!=0xf0)
     { sccode=0xfe;        
      while((sccode&0x10)!=0)
      { P1=sccode;
        if((P1&0xf0)!=0xf0)
        {recode=(P1&0xf0)|0x0f;
        return((~sccode)+(~recode));
        }
        else
        {sccode=(sccode<<1)|0x01;}
      }

     }
     else
     return(0);
   }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -