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

📄 keyscan.c

📁 数码管显示的显示和编程
💻 C
字号:

/********************************************************************
//模 块 名 :  按键演示程序
//创 建 者 :  杨 勇	 
      日期 :   2007年4月29日 18:45				
//修 改 者 : 									
      日期 :
//功能描述 :  
//其他说明 :  22.1184MHz晶振 
//芯片型号 :   AT89S52
//配    置 : 
//版    本 :  V1.0
********************************************************************/

 #include "reg52.h"
 

#define uchar unsigned char
#define uint  unsigned int

	   
uchar KeyBoard_Scan(void); 
void Delay(uchar Delay);

extern void Uart_Send_Byte(uchar Data);

///////////////////////////////
uchar KeyBoard_Scan(void)
{
  uchar Key;

  P2 =0xff;
  P2 &=0x7f;
  Delay(10);
  if(P2 != 0x7f)
  { 
    Key =0x80 | ((~P2) & 0x0f);
    while(P2 !=0x7f);
    return ( Key );
  }
  else
  {
    P2 =0xff;
    P2 &=0xbf;
    Delay(10);
    if( P2 != 0xbf)
    {   
      Key =0x40 | ((~P2) & 0x0f);
      while(P2 !=0xbf);
      return ( Key );

    }
    else
    {
      P2 =0xff;
      P2 &=0xdf;
	  Delay(10);
      if( P2 != 0xdf)
      {
       
        Key =0x20 | ((~P2) & 0x0f);
        while(P2 !=0xdf);
        return ( Key );
      }
      else
      {
        P2 =0xff;
        P2 &=0xef;
		Delay(10);
        if( P2 != 0xef)
        {
         
          Key =0x10 | ((~P2) & 0x0f);
          while(P2 !=0xef);
          return ( Key );	
        }
		else
		{
          return(0x00);
		}
      }  
    }  
  }
  
}

///////////////////////////////////
void Delay(uchar Delay)
{
  uchar i;
  for( ; Delay>0; Delay--)
    for(i=200; i>0; i--);
}

⌨️ 快捷键说明

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