我正在遵循此处找到的教程:https://www.linkedin.com/pulse/prepare-your-raspberry-pi-work-aws-iot-kay-lerch
I have not even begun the internet part of it as I was having issues with the circuit. I wired my circuit just like it is shown in this diagram below using my raspberry pi 3.
然后我编写了以下 python 脚本,如教程中所示。
import RPi.GPIO as gpio
gpio.setmode(gpio.BOARD)
gpio.setup(7, gpio.IN, pull_up_down=gpio.PUD_DOWN)
def on_pushdown(channel):
print "Button Pushed."
while(True):
gpio.add_event_detect(7, gpio.RISING, callback=on_pushdown, bouncetime=200)
gpio.cleanup()
当我按下按钮时,这应该打印出“Button Pushed”,但出现以下运行时错误:
Traceback (most recent call last):
File "button.py", line 10, in <module>
gpio.add_event_detect(7, gpio.RISING, callback=on_pushdown, bouncetime=200)
RuntimeError: Conflicting edge detection already enabled for this GPIO channel
我有 RPi.GPIO 版本 0.6.2,这是撰写本文时的最新版本。我将不胜感激任何人可以提供的任何帮助。