Edited by plural at May 19, 2017 20:10 |
I'm trying to get edge detection and interrupts working on a Banana Pro in Python3 using the LeMaker RPi.GPIO module.
My example code is as follows:
Copy the Code
- import RPi.GPIO as GPIO
- import time
- # We have a momentary switch and 1k resistor in series connecting from this pin to ground:
- INT_PIN_NUM = 26
- # Pull the pin up to detect the falling edge
- def my_callback(channel):
- print("Now value of the Pin is %d".format(GPIO.input(INT_PIN_NUM)))
- GPIO.add_event_detect(INT_PIN_NUM,GPIO.FALLING,callback = my_callback,bouncetime = 300)
- while True:
- except KeyboardInterrupt:
...but I can't get the callback to fire. I can verify (using gpio -g read 26) that the level of pin 26 drops to zero when I press the button, but the callback function never runs.
I've tried this code with every available GPIO port on the BananaPro, and I couldn't get any of them to work.
I've gotten other parts of the RPi.GPIO module to work fine under python3.4 (.VERSION, simple input, output, and reads).
Looking through the sources of the (outdated?) LMK.GPIO module, I saw the following note:
Copy the Code
- #The following pins support the external event detected on the 40Pin Header of the BananaPro
- ''P7 P8 P10 P11 P13 P15 P16 P18 P19 P21 P22 P23 P24 P26'''
...which seems to imply that any of the above pins can handle interrupts.
I'm at something of a loss; can anyone see anyhting I'm doing wrong?
Happy to test anything as needed, etc. Thanks!