Interrupts and RPi.GPIO on the Banana Pro

0 63
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:

  1. import RPi.GPIO as GPIO
  2. import time

  3. # We have a momentary switch and 1k resistor in series connecting from this pin to ground:
  4. INT_PIN_NUM = 26

  5. GPIO.setmode(GPIO.BCM)
  6. # Pull the pin up to detect the falling edge

  8. def my_callback(channel):
  9.     print("Now value of the Pin is %d".format(GPIO.input(INT_PIN_NUM)))

  10. GPIO.add_event_detect(INT_PIN_NUM,GPIO.FALLING,callback = my_callback,bouncetime = 300)

  11. try:
  12.     while True:
  13.         time.sleep(1)
  14. except KeyboardInterrupt:
  15.     pass
  16. finally:
  17.     GPIO.cleanup()
Copy the Code

...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:

  1. #The following pins support the external event detected on the 40Pin Header of the BananaPro
  2. ''P7 P8 P10 P11 P13 P15 P16 P18 P19 P21 P22 P23 P24 P26'''
Copy the Code

...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!
You have to log in before you can reply Login | Sign Up

Points Rules