我們熱衷於DIY自己的想像力,歡迎任何有相同興趣的人來一起研究
您好,想請問一下,您在轉彎這一塊是怎麼寫的?
搭配L9110 motor driver模塊, 整個程式碼如下//** 車子停止 ************************************************************************************************void CarStop() { analogWrite(RightBackward_PWM, 0); analogWrite(RightForward_PWM, 0); analogWrite(LeftBackward_PWM, 0); analogWrite(LeftForward_PWM, 0); }//** 車子前進 ************************************************************************************************void CarGoForward() { analogWrite(RightForward_PWM, RightWheelSpeed+RightWheelDiffSpeed); //RightWheelDiffSpeed是預先修正的值, 讓車子能走直線 analogWrite(LeftForward_PWM, LeftWheelSpeed); analogWrite(RightBackward_PWM, 0); analogWrite(LeftBackward_PWM, 0); } //** 車子後退 ************************************************************************************************void CarGoBackward() { analogWrite(RightForward_PWM, 0); analogWrite(LeftForward_PWM, 0); analogWrite(RightBackward_PWM, RightWheelSpeed); analogWrite(LeftBackward_PWM, LeftWheelSpeed+50); }//** 車子左轉 ************************************************************************************************void CarGoLeft() { analogWrite(RightForward_PWM, RightWheelSpeed+HIGHSPEED); analogWrite(LeftForward_PWM, 0); analogWrite(RightBackward_PWM, 0); analogWrite(LeftBackward_PWM, LeftWheelSpeed+LOWSPEED); }//** 車子右轉 ************************************************************************************************void CarGoRight() { analogWrite(RightForward_PWM, 0); analogWrite(LeftForward_PWM, LeftWheelSpeed+HIGHSPEED); analogWrite(RightBackward_PWM, RightWheelSpeed+LOWSPEED); analogWrite(LeftBackward_PWM, 0); }//** 車子往左上轉 ************************************************************************************************void CarGoUpLeft() { analogWrite(RightForward_PWM, RightWheelSpeed+HIGHSPEED); analogWrite(LeftForward_PWM, LeftWheelSpeed+LOWSPEED); analogWrite(RightBackward_PWM, 0); analogWrite(LeftBackward_PWM, 0); }//** 車子往右上轉 ************************************************************************************************void CarGoUpRight() { analogWrite(RightForward_PWM, RightWheelSpeed+LOWSPEED); analogWrite(LeftForward_PWM, LeftWheelSpeed+HIGHSPEED); analogWrite(RightBackward_PWM, 0); analogWrite(LeftBackward_PWM, 0); }//** 車子往左下轉 ************************************************************************************************void CarGoDownLeft() { analogWrite(RightForward_PWM, 0); analogWrite(LeftForward_PWM, 0); analogWrite(RightBackward_PWM, RightWheelSpeed+HIGHSPEED); analogWrite(LeftBackward_PWM, LeftWheelSpeed+LOWSPEED); }//** 車子往右下轉 ************************************************************************************************void CarGoDownRight() { analogWrite(RightForward_PWM, 0); analogWrite(LeftForward_PWM, 0); analogWrite(RightBackward_PWM, RightWheelSpeed+LOWSPEED); analogWrite(LeftBackward_PWM, LeftWheelSpeed+HIGHSPEED); }
作者已經移除這則留言。
您好! 想請問您 藍芽搖桿是哪一款呢?
這一款 http://goods.ruten.com.tw/item/show?21553486635390 , 我從沒屋頂買來後自己再改成我想要的, 詳見 https://nhs-tw.blogspot.tw/2015/05/arduino-diy.html
歡迎大家來討論交流一下~~~
您好,想請問一下,
回覆刪除您在轉彎這一塊是怎麼寫的?
搭配L9110 motor driver模塊, 整個程式碼如下
刪除//** 車子停止 ************************************************************************************************
void CarStop() {
analogWrite(RightBackward_PWM, 0);
analogWrite(RightForward_PWM, 0);
analogWrite(LeftBackward_PWM, 0);
analogWrite(LeftForward_PWM, 0);
}
//** 車子前進 ************************************************************************************************
void CarGoForward() {
analogWrite(RightForward_PWM, RightWheelSpeed+RightWheelDiffSpeed); //RightWheelDiffSpeed是預先修正的值, 讓車子能走直線
analogWrite(LeftForward_PWM, LeftWheelSpeed);
analogWrite(RightBackward_PWM, 0);
analogWrite(LeftBackward_PWM, 0);
}
//** 車子後退 ************************************************************************************************
void CarGoBackward() {
analogWrite(RightForward_PWM, 0);
analogWrite(LeftForward_PWM, 0);
analogWrite(RightBackward_PWM, RightWheelSpeed);
analogWrite(LeftBackward_PWM, LeftWheelSpeed+50);
}
//** 車子左轉 ************************************************************************************************
void CarGoLeft() {
analogWrite(RightForward_PWM, RightWheelSpeed+HIGHSPEED);
analogWrite(LeftForward_PWM, 0);
analogWrite(RightBackward_PWM, 0);
analogWrite(LeftBackward_PWM, LeftWheelSpeed+LOWSPEED);
}
//** 車子右轉 ************************************************************************************************
void CarGoRight() {
analogWrite(RightForward_PWM, 0);
analogWrite(LeftForward_PWM, LeftWheelSpeed+HIGHSPEED);
analogWrite(RightBackward_PWM, RightWheelSpeed+LOWSPEED);
analogWrite(LeftBackward_PWM, 0);
}
//** 車子往左上轉 ************************************************************************************************
void CarGoUpLeft() {
analogWrite(RightForward_PWM, RightWheelSpeed+HIGHSPEED);
analogWrite(LeftForward_PWM, LeftWheelSpeed+LOWSPEED);
analogWrite(RightBackward_PWM, 0);
analogWrite(LeftBackward_PWM, 0);
}
//** 車子往右上轉 ************************************************************************************************
void CarGoUpRight() {
analogWrite(RightForward_PWM, RightWheelSpeed+LOWSPEED);
analogWrite(LeftForward_PWM, LeftWheelSpeed+HIGHSPEED);
analogWrite(RightBackward_PWM, 0);
analogWrite(LeftBackward_PWM, 0);
}
//** 車子往左下轉 ************************************************************************************************
void CarGoDownLeft() {
analogWrite(RightForward_PWM, 0);
analogWrite(LeftForward_PWM, 0);
analogWrite(RightBackward_PWM, RightWheelSpeed+HIGHSPEED);
analogWrite(LeftBackward_PWM, LeftWheelSpeed+LOWSPEED);
}
//** 車子往右下轉 ************************************************************************************************
void CarGoDownRight() {
analogWrite(RightForward_PWM, 0);
analogWrite(LeftForward_PWM, 0);
analogWrite(RightBackward_PWM, RightWheelSpeed+LOWSPEED);
analogWrite(LeftBackward_PWM, LeftWheelSpeed+HIGHSPEED);
}
作者已經移除這則留言。
回覆刪除您好! 想請問您 藍芽搖桿是哪一款呢?
回覆刪除這一款 http://goods.ruten.com.tw/item/show?21553486635390 , 我從沒屋頂買來後自己再改成我想要的, 詳見 https://nhs-tw.blogspot.tw/2015/05/arduino-diy.html
刪除