logo
Loading...

請問:如果繼電器是低電位觸發,要怎麼設?? active_high=?initial_value=? - Cupoy

開始時設定動作狀態為假(GPIO為0, active_high=False) 初始狀態值設定為關閉:...

請問:如果繼電器是低電位觸發,要怎麼設?? active_high=?initial_value=?

2020/12/21 下午 05:43
使用 Python 控制 DHT22 感測器與繼電器
yaws508
觀看數:197
回答數:2
收藏數:0

開始時設定動作狀態為假(GPIO為0, active_high=False) 初始狀態值設定為關閉: (initial_value=False) 講義範例設法如下: relay = gpiozero.OutputDevice(RELAY_PIN, active_high=False, initial_value=False) 作業範例設法如下: relay = gpiozero.OutputDevice(RELAY_PIN, active_high=False, initial_value=True) 請問什麼時候要設active_high=True ,什麼時候要設initial_value=True 如果繼電器是低電位觸發,要怎麼設?

回答列表

  • 2020/12/22 上午 09:46
    Jeffrey
    贊同數:0
    不贊同數:0
    留言數:2

    1. 一般電路設計, 低電壓為0, 高電壓(需參考裝置設定: 1.2V/1.8V/3.3V) 為1; 所以, 若是要讓裝置動作, active_high=True 2. initial_value=True表示: 裝置一開機(或是通電) 是要被啟動的, 比如說 LED 要亮 3. 繼電器是低電位觸發或是高電位觸發, 都是可以用同樣的參數做設定

  • 2020/12/25 下午 06:02
    張維元 (WeiYuan)
    贊同數:0
    不贊同數:0
    留言數:0

    嗨,你好
    建議可以先看一下 [文件](https://gpiozero.readthedocs.io/en/stable/api_output.html): * active_high (bool) – If True (the default), the LED will operate normally with the circuit described above. If False you should wire the cathode to the GPIO pin, and the anode to a 3V3 pin (via a limiting resistor). * initial_value (bool or None) – If False (the default), the LED will be off initially. If None, the LED will be left in whatever state the pin is found in when configured for output (warning: this can be on). If True, the LED will be switched on initially.

    嗨,你好,我是維元,持續在不同的平台發表對 #資料科學、 #網頁開發 或 #軟體職涯 相關的文章。如果對於內文有疑問都歡迎與我們進一步的交流,都可以追蹤我的 Facebook技術部落格 ,也會不定時的舉辦分享活動,一起來玩玩吧 ヽ(●´∀`●)ノ