Switch 開關橋

Switch 是一個開關橋 , 我們需要2個「Input」才能使用這個 behavior ;
首先 , 設定1個「Input」為橋 , 作用是讓電路變得完整 , 形成閉合電路 ;
然後 , 設定另1個「Input」為開關 , 當電路閉合後用作開啟「Output」。

影片教學 :
所需用料 :
SAM Output blocks x 1
SAM Button x 2
iPad x 1
Switch Behavior Block x 1 (無實物)
編程教學
Ex1. 利用Button開啟RGB LED
只要把兩者連接在一起便能運作。

Ex2. 建立Switch(開關橋)
1. 在「Behaviors」中的「Switches」拖拉「Switch」至工作台。

2. 把當作橋/switch的「Button」連至「Switch」上。

3. 按下「Switch」的設定。

4. Choose Hand 選為「Button 1」, 意思是把「Button 1」當成橋/Switch。

5. 設定後 , 按下「Button 1 」 , 「Switch」會變成閉合狀態。

6. 把另1個「Button」及「RGB LED」加至「Switch」上。

7. 嘗試只按下「Button 2」, 你會發現「RGB LED」不會開啟。
因為「Switch」沒形成關合電路。

8. 嘗試只按下「Button 1」, 你會發現「RGB LED」不會開啟。
因為「Switch」雖然有形成關合電路, 但沒有按下「Button 2」的開關制。

9. 先按下「Button 1」然後再按「Button 2」, 看看「RGB LED」的反應。
* 「RGB LED」會開啟 , 因為同時滿足了關合電路跟開啟的條件。

Switch 應用例子
「Switch」的特性就像一個安全開關裝置 , 我們需先按下安全開關, 然後再按下電源開關 , 才能開啟家具。 例子 : 設有安全制的拖板/插座。

