Ship sea-saw BBC micro:bit coding
Micro:bit IO board coding
如未能下載建議使用firefox browser來開啟網頁
編程說明 :

在on start 把 led enable 設為 false 的目的是把micro:bit screen的led關閉 ,
因為Sea-saw 需使用多個 Pins , 而micro:bit led screen 默認會使用了P9跟P10 ,
我們需要手動關閉 micro:bit led screen 才能利用 P9,P10 進行編程。
P13 , P14 是light gate 的聚光燈 , 我們可以在 on start 時便把它開啟 , 從而啟動光欄系統。

set delta_Second to 1 是方便我們有一個常規的秒數 , 以方便程時寫使用 ,
你也能把所有「Delta_Second」的位置改為「pause (ms) 1000」。
call Slowly_descend_to_starting_Point 是一個function , 我們在編程很常會利用function來減少一個程式的長度, 這有助我們進行修改及除錯。
在開始時命令海盜船緩慢地返回起點的目的是 :
- 模型有可能在完結時/移動後是在高點而不是起點 , 如果手動推動海盜船便有反智能的原則而且返回起點才能乘載客人及開始運作。

當海盜船緩慢地移動到能夠遮掩光欄裝置時 i.e. P1 =/= 1 時 (P1不等於1時)
便會離開 while loop , 並 call 另一個function 「Swing-Stop」命令海盜船停下。
*** 光欄在光線直線到light sensor(P1) 時是 P1 = 1 , 被遮掩時是 P1 = 0 。

Swing-Stop 的 function 非常簡單 , 只要把 P10/P12 寫成 0 ,i.e. 把MOTOR停止運動。
*** P10/P12 是海盜船的MOTOR , (根據電路接駁方法教學)。

接下來是另一組 while loop , 當 digital read pin P0 = 1 , 即Button B被按下時。
代表海盜船載客後開始啟動 , 會進行8次的順逆時針的轉動。
運轉8次後會再call 「Slowly_descend_to_starting_Point」這個function ,
讓海盜船返回起點 , 讓客人下船。

Swing_Clockwise 是 P10 = 1 , P12 = 0 ;
Swing_Anticlockwise 是 P10 = 0 , P12 = 1 。
如果方向不對的話代表你插線有出錯 , 把正負插反了。

else if 是確保海盜船能透過手動命令返回起點 , 由於 「 call Slowly_desced_to_starting_Point」這個function內是 Call Swing_Clockwise , 代表在一般情況下海盜船只能在順時針下自動返回起點。
而在需逆時針轉動返回起點的情況下 , 這個function只會讓海盜船愈升愈高,無法降下。
有見及此 , 我們設置了 Button A i.e. digital read pin P6 = 1 , 當按下它時 ,
海盜船便會先以逆時針移動到能有效 「call Slowly_desced_to_starting_Point」的位置上。

最後這2個function是為了確保Button B / P0 能順利運作才加添。不加到Coding內也是正常運作。
Micro:bit Motor Driver board coding
如未能下載建議使用firefox browser來開啟網頁