欧美极品高清xxxxhd,国产日产欧美最新,无码AV国产东京热AV无码,国产精品人与动性XXX,国产传媒亚洲综合一区二区,四库影院永久国产精品,毛片免费免费高清视频,福利所导航夜趣136

標題: 單片機定時器內(nèi)的按鍵總是處于按下狀態(tài)? [打印本頁]

作者: samxon    時間: 2024-7-9 15:31
標題: 單片機定時器內(nèi)的按鍵總是處于按下狀態(tài)?
單片機定時器內(nèi)的按鍵總是處于按下狀態(tài)。實際并沒有按下。要實現(xiàn)松開按鈕有效該怎么實現(xiàn)。

不想在while(state=1),while(state=2),while(state=3)內(nèi)增加按鍵跳出按鈕,想通過定時器掃描按鍵狀態(tài),不成功,總是檢測到K2已按下,請幫忙看看。


定時器內(nèi)代碼
                static unsigned char presscount=0; //K2按鍵掃描
               
                if(state==1||state==2||state==3){
                        if(K2==0){
                                presscount++;
                                if(presscount>100){
                                        if(K2==0){
                                                        
                                                        state=0;//返回        
                                                        presscount=0;
                                        }        else{
                                                presscount=0;
                                        }                        
                                }                        
                        }               
                }


作者: xiaobendan001    時間: 2024-7-9 18:40
k2==0是按下狀態(tài)?
作者: a825563619    時間: 2024-7-9 22:28
k2不按會==1嗎
作者: lkc8210    時間: 2024-7-9 22:35
  1. static unsigned char presscount=0; //K2按鍵掃描

  2. if(state==1||state==2||state==3)
  3. {
  4.         if(K2==0)
  5.         {
  6.                 presscount++;
  7.                 if(presscount>100)
  8.                 {
  9.                         state=0;//返回
  10.                         presscount=0;
  11.                 }
  12.         }
  13.         else
  14.         {
  15.                 presscount=0;
  16.         }
  17. }
復制代碼

作者: 1481509156    時間: 2024-7-10 10:15
static unsigned char presscount=0; //K2按鍵掃描
if(state==1||state==2||state==3)
{
        if(K2==0)
        {        
        presscount++;
        if(presscount>100)
      {
           while(K2)
           {
                                                        
                state=0;//返回        
                 presscount=0;
          }        
                  
     }                        
      }                                
}
作者: samxon    時間: 2024-7-22 22:01
1481509156 發(fā)表于 2024-7-10 10:15
static unsigned char presscount=0; //K2按鍵掃描
if(state==1||state==2||state==3)
{

完全沒問題,完美解決。




歡迎光臨 (http://www.raoushi.com/bbs/) Powered by Discuz! X3.1