舵舵机控制C程序
舵舵机控制C程序,大家参考参考挺不错的!!kev state=0;//按键凵拾起,属」「扰,转换到按键初始态breakaseif (key pre1)key return= key value;//按键释放后再输岀键值,如果按下键就输出则可省略ey valuekey value=okey stale-0;//如果按键释放,转换到按键初始态breakreturn key return.;//返回键值半*事冰之本咔冰本冰事水客半半半半半客冰半冰半半半半**冰光冰半客*名称:按键处理功能:*字字字半字*率半毕半字字半毕半半掌*字半半字字半掌学半半家毕字率半字/void key operation (void)switch( keyscan0)/根据健值不同,执行不同的内容case 1votage=lf(hight votagehight votage=5breakhight, votage+=if (hight votage)25)hight vot age=25defaultreaAED显示函数iplayi( hight votage>=5& &hight votage<=7)P1=0xF;/1灯亮,舵机接近或到达右转极限位置if(hight votage?7&hight votage<=10)P10xFB: /2 ITmif(hight votage)10&&hight votage(=13)I1=0xl7: //3i( hight volage>l3& &highl ve lage<-16)F1-0xEF;//4灯亮,舵机到达中间位置ir( hight votage)l6&匙 hight votage<=19)P1=0xDF;//5灯亮if hight votage>19&hight votage(=22)F1=0xBF; / /6]TLi( hight votage>22& &hight votage<=25)Pl=0xTF;//7灯亮,舵机接近或到达左转极限位置/米主程序*d main(void)TimerInit(key operation olay(
用户评论