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