STEP 9: Our sprite can only move left. What about the B button?

An event is a block of code that runs when something happens—like when someone presses a button.

  • In SUBJECT, click on . Then, drag in the block B Button Press to the bottom of your editor.
  • Click Run and press B on your micro:bit. Your sprite should move right.

To navigate the page using the TAB key, first press ESC to exit the code editor.

microbit = codesters.Microbit() microbit.show_string("hello") stage.set_background("soccerfield") sprite = codesters.Sprite("athlete2") sprite.move_down(150) def button_a(): sprite.move_left(50) microbit.event_button_a(button_a)
  • Run Code
  • Submit Work
  • Next Activity
  • Show Console
  • Reset Code Editor
  • Codesters How To (opens in a new tab)