Odd button function ... any ideas?

I’ve noticed that whenever you used the “on button pressed” functions, what actually seems to happen is the trigger is made on the button’s release. This makes me wonder why there is an “on button release” ability, or whether it is somehow different.

Try it for yourself. Set your microbit to do something , like play a tone, with button A as a trigger. Sure enough, you’ll notice that the tone will not happen when pressing the button of your physical microbit until you actually release the button.

You can set up your own button on a pin in the same way, and use “on pin pressed” instead. Basically connect one lead of your button to a micdrobit pin, and the other lead to groun. The same thing happens… the trigger executes only after release of the button.

I’ve tried many things to get around this, and I’ve found the only way to do it is to test the digital value of a pin in the forever loop with an if statement. But even then, you can’t set up your button on a pin in the same way as above. Intead, one lead of your button is connected to voltage, and the other lead is connected both to the microbit pin and to ground (with a resistor between ground and the button lead).

It seems silly that the default buttons (A, B, A+B) and simply connected pins trigger only on release, especially when there is a separate on release function.

Is this a bug of the device? Or is there a reason behind it? Also, do you know of a better workaround. I would love to click the A button and hold it down to make something continuous happen, which stops on release, but I can’t seem to make that happen right now with this strangeness.

Also true with capacitive touch buttons - trigger doesn’t happen until pin is released, making it difficult to controlled a sustained action.

This can be done by programming the Microbit in python. Have a look at http://microbit-micropython.readthedocs.io/en/latest/button.html . I’ve just tested the example and it does work as you want