久久r热视频,国产午夜精品一区二区三区视频,亚洲精品自拍偷拍,欧美日韩精品二区

您的位置:首頁技術文章
文章詳情頁

python - RPi.GPIO中wait_for_edge和event_detected有什么區別?

瀏覽:112日期:2022-07-30 10:29:31

問題描述

比如說我要監聽一個下降沿觸發的中斷請求,并且執行一段函數,究竟該怎么寫代碼,網上各種文檔都是互相抄襲國外的機翻文檔,完全無法正常閱讀,請各位高手幫忙解答一下,謝謝!!!

問題解答

回答1:

The wait_for_edge() function is designed to block execution of your program until an edge is detected.

翻譯過來就是wait_for_edge會阻塞程序,直到有一個邊沿事件被觸發

The event_detected() function is designed to be used in a loop with other things, but unlike polling it is not going to miss the change in state of an input while the CPU is busy working on other things.

event_detected就是事件觸發

具體到你這里,要中斷請求,那只能是用事件方式觸發了。

那第一步是讓接口電阻上拉

GPIO.setup(channel, GPIO.IN, pull_up_down=GPIO.PUD_UP)

然后

GPIO.add_event_detect(channel, GPIO.FALLING)GPIO.add_event_callback(channel, callback_func)

標簽: Python 編程
相關文章:
主站蜘蛛池模板: 武冈市| 西贡区| 西乌| 白朗县| 郧西县| 扎囊县| 聂拉木县| 兴仁县| 陆川县| 望奎县| 阜新| 绿春县| 扎兰屯市| 乌鲁木齐市| 大宁县| 米林县| 荥阳市| 榆中县| 南汇区| 江口县| 卫辉市| 益阳市| 尼玛县| 大名县| 沁源县| 吉水县| 永州市| 寿宁县| 卢氏县| 三门县| 天台县| 卢湾区| 萝北县| 兴安盟| 彭水| 涪陵区| 扎兰屯市| 高台县| 安福县| 航空| 武冈市|