[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?
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)
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: