There are two buttons on the board, called
Buttoninstance (see below) representing the left button.
Represents the right button.
Represents a button.
This class is not actually available to the user, it is only used by the two button instances, which are provided already initialized.
Trueif the specified button
buttonis currently being held down, and
Falseto indicate if the button was pressed (went from up to down) since the device started or the last time this method was called. Calling this method will clear the press state so that the button must be pressed again before this method will return
Returns the running total of button presses, and resets this total to zero before returning.
import microbit while True: if microbit.button_a.is_pressed() and microbit.button_b.is_pressed(): microbit.display.scroll("AB") break elif microbit.button_a.is_pressed(): microbit.display.scroll("A") elif microbit.button_b.is_pressed(): microbit.display.scroll("B") microbit.sleep(100)