1
我使用的覆盆子裨3模型B.无法添加边缘检测 - 覆盆子裨3 GPIO
我试图同时使用gpiozero
和RPi.GPIO
不同的方法。无论使用何种库,都会出现问题。
以下是gpiozero
失败的代码示例。
from gpiozero import Button
from signal import pause
def handle():
print("Pressed!")
button = None
while not button:
try:
button = Button(4, pull_up=True)
button.when_pressed = handle
except RuntimeError as e:
print(e)
pass
pause()
线button = Button(4, pull_up=True)
总是引起了RuntimeError
和程序(运行python3
)的输出是:
Failed to add edge detection
Failed to add edge detection
Failed to add edge detection
Failed to add edge detection
# ... it goes on for ages
我已经尝试过重新安装RPi.GPIO
和gpiozero
但它并没有帮助。
这里是例外
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/gpiozero/input_devices.py", line 84, in __init__
self.pin.when_changed = self._fire_events
File "/usr/lib/python3/dist-packages/gpiozero/pins/__init__.py", line 240, in <lambda>
lambda self, value: self._set_when_changed(value),
File "/usr/lib/python3/dist-packages/gpiozero/pins/rpigpio.py", line 233, in _set_when_changed
bouncetime=self._bounce)
RuntimeError: Failed to add edge detection