#include
sbit KEY = P3^3;
sbit LED = P3^6;
void delay20ms(void)
{
unsigned char a,b;
for(b=146;b>0;b--)
for(a=67;a>0;a--);
}
main()
{
KEY = 1;
while(1)
{
if(KEY==0)
{
delay20ms(); //消除按键抖动
if(KEY==0)
{
while(KEY==0); //等待按键放开
LED = ~LED;
}
}
}
}