Raspberry Pi RuntimeError:此GPIO通道已启用冲突边缘检测

Raspberry Pi RuntimeError:此GPIO通道已启用冲突边缘检测,第1张

Raspberry Pi RuntimeError:此GPIO通道已启用冲突边缘检测

您拥有的代码不断地(在

while(True)
循环中)添加事件检测回调。您要添加一次事件检测回调,然后等待边缘。

此页面上有一个很好的示例,您可能需要阅读一下。

或者,您可以尝试以下 *** 作:

import RPi.GPIO as gpiogpio.setmode(gpio.BOARD)gpio.setup(7, gpio.IN, pull_up_down=gpio.PUD_DOWN)def on_pushdown(channel):    print "Button Pushed."# only add the detection call once!gpio.add_event_detect(7, gpio.RISING, callback=on_pushdown, bouncetime=200)while(True):    try:        # do any other processing, while waiting for the edge detection        sleep(1) # sleep 1 sec    finally:        gpio.cleanup()


欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/zaji/5668398.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-12-16
下一篇 2022-12-16

发表评论

登录后才能评论

评论列表(0条)

保存