[WiPy 2.0] cannot configure Pin to generate interrupts
-
I am trying to set up a simple button on WiPy 2.0 with Expansion board. I have updated the firmware to v1.8.6:
import os os.uname() # (sysname='WiPy', nodename='WiPy', release='1.6.3.b1', version='v1.8.6-463-g468b9d27 on 2017-02-16', machine='WiPy with ESP32')When I am trying to register a event handler like they did in the docs, the
irq()function seems not to be available:from machine import Pin def pin_handler(pin): print(pin.id()) pin_int = Pin('G17', mode=Pin.IN, pull=Pin.PULL_DOWN) pin_int.irq(trigger=Pin.IRQ_RISING, handler=pin_handler) # File "<stdin>", line 7, in <module> # AttributeError: 'Pin' object has no attribute 'irq'Am I doing something wrong or is the function really missing?
Is there another way to get a simple, external button working on the WiPy?
-
You're following the Micropython.org docs but this is done differently on the latest Pycom boards.
Follow the Pycom documentation instead:
more specifically what you need to is to create a Pin.callback() function:
https://docs.pycom.io/pycom_esp32/library/machine.Pin.html#machine.pin.callback
-
Thank you, this has solved the issue:
pin_int = Pin('P10', mode=Pin.IN, pull=Pin.PULL_DOWN) pin_int.callback(Pin.IRQ_RISING, pin_handler)
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