Photo Transistor & Resistor

Photo Transistor 跟 Resistor 都是感測光線的 Input ,

Photo Transistor 所感測的是 state i.e 光或暗 ; 是一個 digital (1 or 0) 的 Input ;

Photo Resistor 則可以感測光線數值 , 是一個 analog ( 0 - 512) 的 Input , 數字愈大光線愈光。

專題目標 :

學會辨識 Photo Transistor 及 Resistor 的分別 ,

同時掌握如何利用它們控制 Output 。

所需用料 :

TXT 4.0 Controller x 1

Photo Transistor x 1

Photo Resistor x 1

LED (output) x 1

電線 x 2

電源 x 1

Photo Transistor - 光欄裝置

我們會製作出一個光欄裝備感測光線 (有沒有人經過) , 有人經過時開啟 LED (output)

電線接駁方法 :

Photo Resistor > I1 ,

LED (光欄) > O1 , O2

LED (提示燈) > O7 , O8

接駁 TXT 4.0 Controller :

詳細的連接方法可查看 : 按此

Controller Configuration :

從 「Input」取出「Photo Transistor」

在 「Output」取出2個LED

將 transistor 放至 Input (I1) , Output 加入2個 LED (O1,O7)

編程教學 :

在「Input」取出「is photo transistor bright」

同時在「Logic」取出 「if do else」

先將 「if do else」放進 「repeat forever 」以檢測 photo transistor 的狀態。

在 「Output」取出2個「set LED ___ on」

開始時先將光欄的 LED 開啟 , 製做出光欄檢測有沒有人經過

有人經過時  = 遮擋 LED 投射到 Photo Transistor 的光線 i.e dark ,

提示燈 (O7 LED)開啟。

否則(有光線) , 關上提示燈(O7 LED)

按「play」傳送並啟動編程 :

有人經過光欄時 , 提示燈會開啟 ; 否則關燈。

光欄裝置影片示範 :

Photo Resistor - 感光裝置

我們將利用 Display Text 來顯示 Photo Resistor 的光線數值

電線接駁方法 :

Photo transistor > I1

LED > O1 , O2

Display Configuration :

加入 2 個 TEXT Display , 一個用作顯示數值 , 一個用作顯示文字「light value :」

將其中一個 TEXT 改成 「light value :」 , 另一個則留空以顯示數值

Controller Configuration :

分別在「Input」取出 Photo Resistor , 「Output」取出「LED」

將 resistor 放至 Input (I1) , Output 加入 LED (O1)

編程教學 :

一樣先將 LED 開啟 , 把「set led on」放至 Program start 的最前面

前往「Display」取出「set input ____ text」

放至「repeat forever」裡面 , 選擇剛才留空的 txt_input

在「Input」取出「get photo resistor value」並放至「abc」的位置

按「play」傳送並啟動編程 :

TXT Controller 的 Display Screen 上應會顯示出 Photo Resistor 感測到的光線數值

如上圖一樣

總結 :

Photo Transistor 用作感測有沒有光線 (DIGITAL)> 觸發 Output

Photo Resistor 用作感測光線數值 (ANALOG) > 再利用數值控制 Output