this code works after the first start of micropython, pressing A prints 1 when pressed, 0 when released
def on_action_btn(pressed):
print(pressed)
import buttons
buttons.attach(buttons.BTN_A, on_action_btn)
however after a soft reset (CTRL+D) this code does not work anymore. Problem when using Thonny which does a soft reset before running a script
However a machine.reset() instead of a machine.soft_reset() makes it work again