loading

This is a sample code created from MIT APP inventor2.To Show how to connect to Andruino thru BT.You can modify it by youself to meet which function you want.Bassically,it is really easy to build a APP to support Arduino +BT projects .

.##這是一個用MIT APP Inventor2 所製作的Andriod APP .透過藍芽連接可以用來控制由Arduino 所做的智慧小車.這是一個完整的範例,你也可以自己修改它來完成其他功能.基本上由MIT APP Inventor2 來製作的Andriod APP 其實非常簡單,很容易就可以達成跟Arduino 做藍芽(BT)連線控制的動作.

See more:阿布拉機的3D列印與機器人

Step 1: APP Layout

This is the APP layout ,At first,put the elements on the Screen1

##首先放所有元件在Screen1.

Step 2: Program Block1

Programming like as blocks.This picture show the initialize variables and do the BT connecting.

用積木拼圖式的方式做程式設計,以上這段做完變數初始化後,便是做來藍芽連線的功能.

Step 3: Program Block2

When push the buttons on the APP Screen to send the "TEXT command" to Anduino thru BT.The " TEXT command" like as "ST","FW","BW","RW","LW" ,you can define them by yourself.then,On Arduino Side ,When Arduino SmartCar get these " TEXT commands" to do the motor actions.Such as when get "ST" then stop the Car.When get the "FW" then let the SmartCar driving forward.

以上的程式當按下APP上的上下左右的按鈕時,在藍芽以連線的狀態下會送出"文字命令" 像"ST","FW","BW","RW","LW" ,這些是純文字形式你可以自己定義他們,例如"ST" 就代表停止,"FW"代表車子往前走.這些"文字命令" 透過藍芽傳到Arduino 智慧小車端,在Arduino的程式裡就可以做對應的控制.

Step 4: Program Block3

Above coding is relative with "checkbox" function.I created 3 checkbox function switch. When Checkbox1 be selected ,It indicated Arduino SmartCar in "Phone controlled mode" and Checkbox2 be selected It indicated Arduino SmartCar in "AUTO mode".The last Checkbox3 be selected means "Search Line mode". Arduino SmartCar can get these "AA"/"BB"/"CC" text command to switch the driving mode.

and change the slide bar can change the car speed.It can send the "P0"-"P9" text to arduino with 10 level speed.

我在這個程式上做了3個 可以勾選切換行車模式的功能,當第一個checkbox被勾選時

會進了自動模式,第二個則是手機遙控模式,第三則是預留給循線模式,當Arduino收到 "AA"/"BB"/"CC"時,即可做出對應模式的切換.另外滑動滑桿則可以改變行車速度.他會送"P0"-"P9"給Arduino ,可以有10階速度調整.

Step 5: Running in Mobile Phone 1

This is the APP running on my Arduino Mobile phone.Firstly,power on the Arduino SmartCar and check BT function be enable on your mobile Phone.then let the mobile Phone seraching the BT (in Arduino SmartCar BT module is HC05 ).after matching the BT then you can push the Button to connect BT in APP.

這是在手機執行的畫面,確定手機藍芽功能有被打開以及在Arduino SmartCar開電後,到手機的設定裡去做藍芽的配對.之後就可以在APP裡按BT連線.

Step 6: Running in Mobile Phone 2

Pushing the Button to connect BT in APP.and select the BT module in Arduino SmartCar.Here is first one HC-05.


按下 Button 後選擇Arduino smartCar上的BT 模組做連線,這裡是第一個HC-05.然後即可做車子控制.

Step 7: Download APP

Download this APP:Arduino SmartCar

Step 8:

<p>The app &quot;Arduino SmartCar&quot; can't be downloaded,please update it!</p>

About This Instructable

915views

23favorites

License:

More by Ashing Tsai:Build the BT_SmartCar with 3DP & Arduino(用3D列印和arduino製作藍芽智慧小車) A Joystick example for Connecting arduino to mblock (scratch 2.0)(一個arduino連結到mblock的範例-搖桿使用)  Building the Android APP to control Arduino Smart Car (製作Android APP控制Arduino 智慧車) 
Add instructable to: