The Microbit_Button
extension provides App Inventor with information about the state of the BBC micro:bit’s buttons. Developers can use this extension to request updates for when a user presses a button or read the current state of the buttons. The buttons have three states:
ReadButtonAState
– Read the current state of the micro:bit’s A button. After a successful read, the
ButtonAStateReceived
event will be run.ReadButtonBState
– Read the current state of the micro:bit’s B button. After a successful read, the
ButtonBStateReceived
event will be run.RequestButtonAStateUpdates
– Request updates to the state of the micro:bit’s A button. After requesting updates, the
ButtonAStateReceived
will be run whenever
the micro:bit reports a button state change to the app. Pressing and holding the button
will result in a second event with the value 2 to indicate a long press.RequestButtonBStateUpdates
– Request updates to the state of the micro:bit’s B button. After requesting updates, the
ButtonBStateReceived
will be run whenever
the micro:bit reports a button state change to the app. Pressing and holding the button will
result in a second event with the value 2 to indicate a long press.StopButtonAStateUpdates
– Stop receiving updates about the state of the micro:bit’s A button. Note that there may
be pending updates that have not been processed that will result in
ButtonAStateReceived
StopButtonBStateUpdates
– Stop receiving updates about the state of the micro:bit’s B button. Note that there may be
pending updates that have not been processed that will result in
ButtonBStateReceived
.ButtonAStateReceived
– After performing a read or
request for updates, the
ButtonAStateReceived
event will be run with information about the button state.
Parameters:
Button_State_Value
(number) — The state of the micro:bit’s A button; 0 for released, 1 for pressed, 2 for long-pressed.ButtonBStateReceived
– After performing a read or
request for updates, the
ButtonBStateReceived
event will be run with information about the button state.
Parameters:
Button_State_Value
(number) — The state of the micro:bit’s B button; 0 for released, 1 for pressed, 2 for long-pressed.