I'm currently looking at adding another button to my script. Currently, it's showing the output of my video (camera) fullscreen until the button press is detected, to then which it will do something. This looks like thisI have done this so:
while True:
camera.preview_fullscreen = True
camera.preview_alpha = 128
camera.start_preview()
GPIO.wait_for_edge(picture_pin, GPIO.FALLING)
action()
However, I'm at the stage I want to introduce another button which does a different action. As such, I was thinking of putting in this:
import RPi.GPIO as GPIO
actionpin1 = 23
actionpin2 = 24
GPIO.setmode(GPIO.BCM)
GPIO.setup(actionpin1, GPIO.IN, pull_up_down=GPIO.PUD_UP)
GPIO.setup(actionpin2, GPIO.IN, pull_up_down=GPIO.PUD_UP)
def action1():
print "button pressed 1"
def action2():
print "button pressed 2"
while True:
print "waiting for button"
GPIO.add_event_detect(actionpin1, GPIO.BOTH, callback=action1, bouncetime=800)
GPIO.add_event_detect(actionpin2, GPIO.BOTH, callback=action2, bouncetime=800)
However, it's giving me this error:
Traceback (most recent call last): File "test.py", line 19, in GPIO.add_event_detect(actionpin1, GPIO.BOTH, callback=action1, bouncetime=800) RuntimeError: Conflicting edge detection already enabled for this GPIO channel
This error conflicts with what I've read on this function, so I'm not sure why it's giving me this error. Can anyone point me in the right direction?
actionpin1andactionpin2? Do you have any GPIO stuff elsewhere in your code ?