Conveyor belt with punch BBC micro:bit coding
Micro:bit IO board coding
如未能下載建議使用firefox browser來開啟網頁
編程說明 :

在on start 把 led enable 設為 false 的目的是把micro:bit screen的led關閉 ,
因為Conveyor belt 需使用多個 Pins , 為了減低micro:bit及I/O board的供電負擔 , 我們先
把不必要的micro:bit screen led 關上 , 以保持運作效能。

在 on start (開機後) 便 Call Punch a stamp 及 TurnOnLight 2個function。
TurnOnLight 的目的是開啟聚光燈以使光欄系統運作以感應有無有物件 ;
Punch a stamp 的目的是先壓下「衝壓機」讓它在開機後必定會返回原處 , 以準備壓下迎來的物件。

Puch a stamp function 先會命令 Motor 開啟(壓下衝壓機) P15=1 , 壓下後Motor會撞到,Switch i.e. P6 會 = 1 , 當 P6 不等0 即是 = 1 時 便會離開 while loop , P15 / P16 便會寫成0, Motor便會關閉等待下一次開啟。

Turn On Light 會把 2個聚光燈都可啟 , 以啟動光欄系統 , 因此 P10跟P8要寫成1。

P1 是第一個光欄 , 是運輸帶的起點部份 , 當放下貨物時便會遮蓋到聚光燈寫向P1的光線 , 因此P1會變成0 , 即需要運貨從而CALL Move Belt Forward。

Move Belt Forward 的Function非常簡單 , 只有 P13 = 1 / P14 = 0 , 命令Motor以順時針運行。

while not digital read pin P4 = 0 裡沒編程是因為物件需運到到P4 = 1 的位置時才Call 其他function (讓物件繼續向前運送 保持P13=1)
當物件到達P4點時 , P4便會=1 (物件遮蓋住聚光燈的光線時) , 會先Call Stop Belt

P13 / P14 = 0 , 命令 Motor 停止轉動 i.e. 運送帶停止運作。

Punch a stamp 跟上面的說明一樣 , 固不再重覆。

壓下衝壓機後 , 把貨物運送回起點進行回收 , 因為 Motor 需以逆時針轉動 , 改為P14 = 1

最後當貨物運回P1點時 , 再Call Stop Belt 完成整個運送過程。