长按3秒进入程序可以这样while(1){ if( key==0)//按键按下 { cnt++; if( cnt>300) { cnt=0;//到3秒,退出本循环进入下一段程序 break;} dely(10);//延时10毫秒}} while(1){ ...//此为主程序段}