Motion sensor (accelerometer)
The Micro:bit has a small chip that feels movement and which way is down. It notices a shake, a tilt to the left or right, and the board lying face up or down.
Events like "on shake" for quick moves; "acceleration (mg)" for how far it is tilted.
More: the numbers
acceleration (mg) x is about 0 when the Micro:bit lies flat, and goes to about −1000 and +1000 when you tilt it fully left or right (mg means thousandths of the pull of the earth). strength adds all directions: a hard swing gives a big number.
The same in Python
def on_gesture_shake(): basic.show_icon(IconNames.SURPRISED) input.on_gesture(Gesture.SHAKE, on_gesture_shake) def on_forever(): led.plot_bar_graph(abs(input.acceleration(Dimension.X)), 1023) basic.forever(on_forever)