我也是新手,不过你看看这样对不对,可以按这个逻辑看看检查下:
if(KEY1 = 1 && key2 = 1) //初始状态无动作
{
delay 1 s;
if(KEY1 =1 && KEY2 =1) //延时一秒按键无动作不按下
{
OUT1= 0;
OUT2 = 0;
}
else
break;
}
else if(KEY1 = 0 || KEY2 = 0) //有按键按下
{
if(KEY1 =0 && KEY2 = 1) //若是轻按
{
{ OUT1= 1;OUT2 = 0;}
delay 1s; //延时一秒
if(KEY1 =1 && KEY2= 0) //判断状态是否切换
OUT2 =1;
else
break;
}
else if(KEY1 =1 && KEY2 = 0) //若是重按
{
OUT1 =1;
OUT2 =1;
delay 1s;
if(KEY1 =0 && KEY2 = 1) //判断状态切换
{
OUT1 = 1;
OUT2 = 0;
}
else
break;
}
else //如果KEY1 =0 KEY2 =0,则无效
break;
}
不知道对不对,你可以看看。大概就是这个意思得逻辑吧。
|