static unsigned char status=1;
BUZ =1;
while(1)
{
switch(status)
{
case 1:
if((0 == key1)||(0 ==key2))
status =2;
break;
case 2:
BUZ =0;delay_ms(500);BUZ=1;
status =3;
break;
case 3:
if(!((0 == key1)||(0 ==key2)))
status =4;
break;
case 4:
BUZ =0;delay_ms(500);BUZ=1;
status =1;
break;
default: status =1;
break;
}
}
static unsigned char status=1;
BUZ =1;
while(1)
{
switch(status)
{
case 1:
if((0 == key1)||(0 ==key2))
status =2;
break;
case 2:
BUZ =0;delay_ms(500);BUZ=1;
status =3;
break;
case 3:
if(!((0 == key1)||(0 ==key2)))
status =4;
break;
case 4:
BUZ =0;delay_ms(500);BUZ=1;
status =1;
break;
default: status =1;
break;
}
}
再不能满足要求你可以照上面稍微改下。上面用状态控制你是在准备接受按下状态还是准备松手状态。
一周热门 更多>