配合 Wappsto:bit 控制小車並收集數據

有見於 gamer:bit 還是會出現 input 不夠萬向輪小車做出所有的移動 Output ,
這次我們將利用 Wappsto:bit 發送文字指令去控制小車移動 , 同時做到收集數據並上傳至雲端。
假如你是首次接觸 Wappsto:bit , 可先看這幾篇有關 Wappsto:bit 的教學 ,
看完後 , 你應對 Wappsto:bit 有基本的概念 , 它是一塊簡易接駁的IoT device 而且還能做到發送指令。
所需材料 :
micro:bit x 2
Omni Wheel car model x 1
Robotics board x 1
Wappsto:bit x 1
編程概覽 :
我們將利用 Wappsto + micro:bit A 以 radio 形式發送文字訊號至 omni wheel car 的 micro:bit B 上,
micro:bit B 收到訊號後便會啟動 Motor , 以不同方向移動以及收集溫度數據。
Wappsto:bit 部份(遙控及發送訊號) :
首先需連接你的Wappsto:bit 詳細教學 : 看此
加入 Extension :

按下 「Advanced」然後再按「Extensions」

輸入「Wappsto」, 選擇 「wappsto」加入Extension。
設定 Wappsto:bit :
在「On start」將 radio group 設成 "1" , 另一塊micro:bit 也需一樣
然後加入「setup micro:bit on Wappsto with name "Car Control"」
Name是專題的名稱 , 在dashboard上已連接的Wappsto:bit會顯示為這個名字。
「setup string value」的作用是能在 dashboard 上輸入文字訊字 ,
Number Value 1 即是dashboard第一組數據 , name "Temp" 是顯示的名稱 ;
as 「Number」則是數據類型 , 也可選擇為其他類別 eg : 「Temp」。
發送訊號 :
Forward :

用家需在 Wappsto dashboard 輸入 「f」 (如下圖的dashboard) ,
接著 micro:bit 會收到 receivedString = f , 並發送 radio number 2 到另一塊micro:bit
同時把 "Forward" 傳送至 Wappsto App 並做出顯示。

Backward / Stop :

跟 Forward 一樣都是大同小異的代碼。
Right / Left :

斜向移動 :

Forward-Right = fr = 右斜向前
Forward-Left = fl = 左斜向前
Backward-Right = br = 右斜倒車
Backward-Left = bl = 左斜倒車
轉左/轉右 :

收集數據 :

先在 Wappsto:bit 上輸入 "temp" 發送指令(radio number 12)到小車的 micro:bit上 ,
小車的micro:bit會收集即時的溫度數據 , 並再以 radio 形式傳回 Wappsto:bit的 micro:bit ( receivedNumber)
Wappsto:bit 收到數據後會在 dashboard 顯示數據。
Omni Wheel Car micro:bit B :

radio group 一樣設成 1 , 這樣才能收到由 gamer:bit 發送的訊號
小車編程 :
向前/後後及停止 | s , f , b :

function 及 向 Motor要怎樣編程已在 gamer:bit 以及 Omni Wheel Car 編程中教過 ,
因此學過的編程跟步驟就先在此省略。
向左/向右 | r , l :

轉右/轉左 : tr , tl
gamer:bit 的編程只有 TurnRight , 我們需補回 TurnLeft 的 function。

reecivedNumber 將會是 10 跟 11 , 需對應 Wappsto:bit 的數字。
收集數據 :

收到Wappsto:bit的指令(radio number 12) , 小車上的 micro:bit 便會收集現場的溫度 , 並把它以 radio number 形式傳回 Wappsto:bit 上以上傳數據至 Wappsto:App。