2015年5月6日 星期三

[arduino] 藍芽手把搖桿和藍芽小車展示影片(8向控制)

藍芽手把搖桿和藍芽小車展示影片, 具有開機自動連線, 手把和車子都可用microusb充電, 車子同時還具有無線充電功能, 手把搖桿目前支援8個方向控制

5 則留言:

  1. 您好,想請問一下,
    您在轉彎這一塊是怎麼寫的?

    回覆刪除
    回覆
    1. 搭配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);
      }

      刪除
  2. 作者已經移除這則留言。

    回覆刪除
  3. 您好! 想請問您 藍芽搖桿是哪一款呢?

    回覆刪除
    回覆
    1. 這一款 http://goods.ruten.com.tw/item/show?21553486635390 , 我從沒屋頂買來後自己再改成我想要的, 詳見 https://nhs-tw.blogspot.tw/2015/05/arduino-diy.html

      刪除

歡迎大家來討論交流一下~~~