#include "key.h"
#include "delay.h"
sbit KEY1 = P1^4;
sbit KEY2 = P1^5;
sbit KEY3 = P1^6;
sbit KEY4 = P1^7;
u8 KEY_Scan(void)
{
static u8 key_up=1;//°´¼ü°´ËÉ¿ª±êÖ¾
if(key_up&&(KEY1==0||KEY2==0||KEY3==0||KEY4==0))
{
delay_us(100);//È¥¶¶¶¯
key_up=0;
if(KEY1==0)return 1;
else if(KEY2==0)return 2;
else if(KEY3==0)return 3;
else if(KEY4==0)return 4;
}else if(KEY1==1&&KEY2==1&&KEY3==1&&KEY4==1)
{
key_up=1;
}
return 0;// ÎÞ°´¼ü°´ÏÂ
}
#ifndef __KEY_H
#define __KEY_H
#include <STC12C5A60S2.H>
u8 KEY_Scan(void); //°´¼üɨÃ躯Êý
#endif