RPI.GPIO Help

hakugin.gin at gmail.com hakugin.gin at gmail.com
Mon Aug 31 20:25:03 CEST 2015


On Monday, August 31, 2015 at 1:42:16 PM UTC-4, John McKenzie wrote:
> Dennis, Hakugin, I tried your scripts and had to alter a typo here or 
> there, but once the basic errors disappeared I had the same error 
> message. "Conflicting edge detection already enabled for this GPIO 
> channel".
> 
>  As much as I despise web based bulletin board systems I registered on 
> the Raspberry Pi website to ask for help as well.
> 
>  Appreciate the effort you both put in those scripts. Will keep working 
> with them and the general points you made.
> 
>  Still checking here and am discussing all this in the Raspberry pi 
> newsgroup. Thanks to the several people who mentioned it.
> 
>  Again, still listening here if anyone has any more to add.

I apologize, I did make a mistake with the example I provided and I just realized it. Change the code block:

while True: 
    GPIO.add_event_detect(22, GPIO.RISING, callback=red_button, bouncetime=200) 
    GPIO.add_event_detect(23, GPIO.RISING, callback=yellow_button, bouncetime=200) 
    GPIO.add_event_detect(24, GPIO.RISING, callback=blue_button, bouncetime=200) 
    if colour == 1: 
        time_red += 1 
    elif colour == 2: 
        time_yellow += 1 
    elif colour == 3: 
        time_blue += 1 

to:

GPIO.add_event_detect(22, GPIO.RISING, callback=red_button, bouncetime=200) 
GPIO.add_event_detect(23, GPIO.RISING, callback=yellow_button, bouncetime=200) 
GPIO.add_event_detect(24, GPIO.RISING, callback=blue_button, bouncetime=200)

while True: 
    if colour == 1: 
        time_red += 1 
    elif colour == 2: 
        time_yellow += 1 
    elif colour == 3: 
        time_blue += 1


You are getting the error because the script is attempting to perform a "add_event_detect" on the same pins each time the "while" loop iterates. By moving it above the loop the error should stop occuring.


More information about the Python-list mailing list