The input.onGesture allows to run code on a number of pre-defined gestures such as shake, freefall or various orientation events.

Live data

The input.acceleration returns the immediate acceleration for a given direction in milli-g, e.g. 1/1000 of a g. The measure includes earth gravity (1000mg) You can query X, Y, Z or the strength.

If you look closely at the center of the Circuit Playground, you will see the accelerometer axis printed on the board.

Assuming the board is at rest on a table,

  • the X axis is aligned horizontally from left to right. If you tilt left, X is negative, tilt right X is positive.
  • the Y axis is aligned vertically from bottom to top. If you tilt forward, Y is positive, tilt backward Y is negative.
  • the Z axis is perpendicular to the board and pointing down. At rest, Z is aligned with earth gravity.


The example below plays a sound when the Circuit Playground is shaken. In a forever loop, it display the accelerometer reading using graph.

This guide was first published on Jun 07, 2017. It was last updated on Jun 07, 2017.

This page (Accelerometer) was last updated on Jun 07, 2017.

Text editor powered by tinymce.