Pin Interrupt not working as expected
My Apologies if this is answered elsewhere. But I'm running into an odd issue that with my Lopy4 and expansion board. I'm setting up a pin with a callback and regardless of what trigger I use it immediately fires off and not again afterwards. Running the following code will immediately kick off the
testing()function, if I press the
back_buttonI can confirm its value goes from 1 to 0 but doesn't fire the callback. I've tried low_level, high_level, rising and falling values for the trigger. All behave the same.
from machine import I2C, Pin import time def testing(): print("test function") back_button = Pin('P8', Pin.IN, Pin.PULL_UP) back_button.callback(Pin.IRQ_FALLING, testing())
For cabling I have a simple button going to
P8on one side and ground on the other.
Calling the callback from the repl returns the following which I'm not sure is expected behavior or not.
>>> back_button.callback(Pin.IRQ_FALLING, testing()) test function
Lopy version info:
Pycom MicroPython 1.20.2.r1 [v1.11-a5aa0b8] on 2020-09-09; LoPy4 with ESP32
Pybytes Version: 1.6.0
Thank you in advance!
@jcaron, I'm such a fool. I had a feeling it had to be something stupid simple. Thank you!
@jackalope remove the
(). You want to pass the function, not the result of calling that function.