The Accelerometer

Most of the inputs provided by the Circuit Playground are relatively simple devices, which give a single value. The accelerometer is a more complex kind of sensor, which measures a number of different things all at once, and therefore provides more complex information to the user. An accelerometer is commonly used to detect movement and position in devices like laptops, phones, virtual reality controllers, and health trackers. For example, pedometers use the movement from accelerometers to track how many steps you take.

Measuring Orientation

The accelerometer can determine the orientation of the board to figure out how the board is positioned.

Orientation Type of Motion Being Tracked Range of Values
Pitch Forward and back motion -90 to 90
Roll Side to side motion -90 to 90
Inclination Rotational motion -180 to 180


Using the accelerometer.getOrientation() block, we write programs that respond to changes in pitch, roll, and inclination. This block returns a number for each of these orientations which indicates which way the board is tilting. For example, pitch is positive when it's being tilted back, and negative when being tilted forward.

Found a bug in the documentation? Let us know at documentation@code.org