Extension board's PIN
I am struggling to find out which PIN the extension board's button is connected to.
I've tried every PIN I found in machine.PIN.boards but without success.
Could you help please?
With a LoPy updated to 0.9.1.b1 (the only one to succeed of four attempted so far), the GPIO (including IRQs) work better. This sample uses an interrupt to make the LED toggle:
import machine led=machine.Pin("G16",machine.Pin.OUT) button=machine.Pin("G17",machine.Pin.IN, pull=machine.Pin.PULL_UP) def handler(button): led.toggle() irq=button.irq(trigger=button.IRQ_FALLING, handler=handler)
Note that the button itself will bounce, so this won't reliably toggle just once per press.
I've managed to read the button, with some effort. It looks like MicroPython 0.9.0.b2 on the LoPy is a little confused about the GPIO functionality.
The button is on expansion board G17 (G16 is the LED), which internally maps to GPIO 10 (luckily this is done for us). However, it needs to be configured to input with pullup, and that's where the example fails us. It was supposed to be:
button = Pin("G17", mode=Pin.IN, pull=Pin.PULL_UP)
However, the PULL_UP mode isn't correctly mapped in this version. I succeeded using mode 3, which it thinks means OPEN_DRAIN:
button = Pin("G17", mode=3)
button.value()read correctly (0 when pressed, otherwise 1).
This is a firmware bug where pullup is not enabled by the pull setting. Hopefully it will be fixed so later versions don't need such hacks.
The Pin is G16. The details can be found in: https://github.com/wipy/wipy/blob/master/docs/User_manual_exp_board.pdf