#include <REGX52.H>
void Delay(unsigned int xms) //定义xms为无符号整型
{
unsigned char i, j;
while(xms)
{
i = 2;
j = 239;
do
{
while (--j);
} while (--i);
xms--; //xms=xms-1
}
}
void main()
{
while(1)
{
if(P3_0==0)
{
Delay(20); //按下犍纽消抖,延迟20ms
while(P3_0==0); //检测按键是否松开
Delay(20);
P2_0=~P2_0; //led与初始状态相反
}
}
}