#include
#define uchar unsigned char
uchar num;
sbit beep=P2^3;
sbit led=P1^0;
sbit k1=P3^4;
void delay(uchar i)
{
uchar j,k;
for(j=i;j>0;j--)
for(k=125;k>0;k--);
}
void main()
{
while(1)
{
if(k1==0)
{
delay(20); //延时
if(k1==20)
{
while(!k1); //等待按键释放
num++;
}
switch(num)
{
case 1: led=0; beep=1; break;
case 2: beep=0; led=1; num=0; break;
}
}
}
阅读(1173) | 评论(0) | 转发(0) |