When ()
3.0 When ().png
Category Event, micro:bit
Type Hat
Introduced in 3.0

The When () block is a micro:bit block and a Hat block, this block can be found by clicking the extension icon on the bottom left of the editor. The block activates if the button on a micro:bit is moved, shaken, or jumped. It can be used in some interesting ways. For example: if a script says shake the micro:bit, you can shake the micro:bit, and the script will activate.

This block is similar to the When () Key Pressed block. When the condition is true, it will run the script.

This block can only be used with a micro:bit.

Values

The block has the following options in the drop-down menu:

  • moved
  • shaken
  • jumped

Example uses

When moved example use 1.PNG Triggering an event on the micro:bit

When moved example use 2.PNG Triggering an event on the project's stage.

See Also