-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Async Pin interupts not working on RPI Pico? #7379
Comments
Hi, To monitor a pin, I would rather advise using the Here is some similar code that uses the keypad module: import asyncio
import keypad
async def catch_button(pin):
"""Print a message when pin goes low."""
with keypad.Keys((pin,), value_when_pressed=False, pull=True) as keys:
while True:
if event := keys.events.get():
if event.pressed:
print(f"Button pressed !")
await asyncio.sleep(0)
async def main():
interrupt_task = asyncio.create_task(catch_button(board.GP26))
await asyncio.gather(interrupt_task)
asyncio.run(main()) If you use multiple buttons, you might want to restructure the code to use a single keypad instance for them rather than one for each button like this code would, and test the key number when a pressed event is detected in the loop, see the keypad guide for that. For further questions and community help I suggest going to the Adafruit discord server or the support forums. |
All makes sense. I’d be fine with closing this issue then unless it would be more useful as a documentation issue. Thank you all. |
I agree we could say something about the pin restrictions in the ReadTheDocs documentation. Turning this into a doc issue. |
As a note about quickly finding GPIO capabilities on the Pico, I really like https://pico.pinout.xyz/ with the “Advanced” box ticked |
CircuitPython version
Code/REPL
Behavior
I'm following the example on https://learn.adafruit.com/cooperative-multitasking-in-circuitpython-with-asyncio/handling-interrupts on a Pimoroni Tiny 2040. I have a momentary button hooked up to GP26 and have modified the source code from the example.
When I run I get:
I'm just trying to get a simple button working - no PWM involved.
Description
No response
Additional information
Error is thrown here I think: https://github.com/adafruit/circuitpython/blob/main/ports/raspberrypi/common-hal/countio/Counter.c#L20
The text was updated successfully, but these errors were encountered: