Example #1
0
/********************************************************************
* 名称 : Main()
* 功能 : 主函数
* 输入 : 无
* 输出 : 无
***********************************************************************/
void Main(void)
{
	uchar Key_Value;  //读出的键值
	L1602_init();
	L1602_string(1,1,"  4*4 KeyBoard  ");
	L1602_string(2,1,"You Press The    ");
	while(1)
	{
		P1 = 0xf0;
		if(P1 != 0xf0)
		{
			Delay_1ms(20);	//按键消抖
			if(P1 != 0xf0)
			{
				Delay_1ms(20);	//按键消抖
				if(P1 != 0xf0)
				{
					Key_Value = Keyscan();		
				}
			}
		}
		L1602_char(2,15,Key_Value / 10 + 48);
		L1602_char(2,16,Key_Value % 10 + 48);		
	}
}
void main(void)
{
	uchar Key_Value;  //读出的键值		
	InitLed();
	InitKey();
	while(1)
	{
		P0 = 0xf0;//亮P0 = 0xff闪
                 //P1 = 0xff;			
		if(P0 != 0xf0)
		{
			Delay_1ms(15);	//按键消抖
			if(P0 != 0xf0)
			{
				Key_Value = Keyscan();		
			}
		}	         
		P1 = table[Key_Value % 16];		//显示低位键值		
		Delay_1ms(5);
	}
}