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

📄 keyscan.h

📁 利用51单片机实现4*4的键盘扫描程序 在多个51平台中验证通过
💻 H
字号:
#define uchar unsigned char
#define uint unsigned int
#define Keyport P2
//*************延时函数*************//
 void dlms(void)
{uchar i;
for(i=200;i>0;i--){}
} 
//*************键盘扫描**************//
uchar keyscan(void)
{ uchar sccode,recode;
Keyport=0xf0;
     if((Keyport&0xf0)!=0xf0)
       { dlms();
            if((Keyport&0xf0)!=0xf0)
              {sccode=0xfe;
               while((sccode&0x10)!=0)
                    {Keyport=sccode;
                     if((Keyport&0xf0)!=0xf0)
                        {recode=(Keyport&0xf0)|0x0f;
                         return((~sccode)+(~recode));
                         }else
                          sccode=(sccode<<1)|0x01;
                    }
               }
		}
return(0);}

⌨️ 快捷键说明

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