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 theback_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 functionLopy version info:
Pycom MicroPython 1.20.2.r1 [v1.11-a5aa0b8] on 2020-09-09; LoPy4 with ESP32
Pybytes Version: 1.6.0Thank you in advance!
-
@jackalope remove the
(). You want to pass the function, not the result of calling that function. -
@jcaron, I'm such a fool. I had a feeling it had to be something stupid simple. Thank you!
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better 💗
Register Login