Hello Accelerometer

Since this project uses the accelerometer, let's start by exploring how it works and behaves. You can read some technical details in the Lesson #0 Guide. And for reference, here is where the accelerometer is located on the Circuit Playground.

There is an example sketch included with the Circuit Playground library that we can use to play around with the accelerometer. It can be found in the following location:

File -> Examples -> Adafruit Circuit Playground -> Hello_CircuitPlayground -> Hello_Accelerometer

With this sketch loaded and running on the Circuit Playground, open the Serial Monitor.

Tools -> Serial Monitor

The current values from the accelerometer will be printed once a second.

Try rotating the Circuit Playground around in various orientations and watch how the values change. The values are in units of m/s2 (meters per second squared). If you are doing this on planet Earth, you will see a value of 9.8 m/s2 showing up when an axis is aligned vertically. This value will be there even if the Circuit Playground is held still and does not move. More on this later.

Another way to watch the values of the accelerometer is to use the Serial Plotter. To do this, let's first modify the code slightly. The code below changes the format of the output to work with the Serial Plotter and increases the rate at which the values are displayed.

#include <Adafruit_CircuitPlayground.h>
#include <Wire.h>
#include <SPI.h>
float X, Y, Z;

void setup() {

void loop() {
  X = CircuitPlayground.motionX();
  Y = CircuitPlayground.motionY();
  Z = CircuitPlayground.motionZ();



With this sketch loaded and running on the Circuit Playground, open the Serial Plotter.

Tools -> Serial Plotter

The accelerometer values will now be plotted like a strip chart as shown below. There should be 3 lines, one each for the X, Y, and Z values. Again, play around with rotating the Circuit Playground and watch the values change.

In the example below, the Circuit Playground was slowly rotated so that each axis aligned with the vertical, held there for a bit, and then rotated again. Finally, it was given a bit of a shake.

Last updated on 2016-10-29 at 01.44.25 PM Published on 2016-10-25 at 12.26.06 PM