Accelerometer

An accelerometer is a MEMS device that reads the acceleration of a device. It can be used to measure motion, like step count, or which way is down, for screen orientation. Most accelerometers use digital communication like serial called I2C or SPI to relate their data. The accelerometer in the kit is from Adafruit.

To use the accelerometer you need to add a library to the ItsyBitsy. Instructions

Connect the accelerometer

The accelerometer needs 4 connections: 3.3V to VDD, ground to VSS, and the data pins, SDA to the ItsyBitsy SDA and SCL to the ItsyBitys SCL.

Plot the data

The values returned for acceleration range from -32000 to +32000, where +16000 is 1g of acceleration. -16000 is -1g, or completely downwards.

Example code

Image of IMU data Accelerometer data in the plotter

Solution

Set the brightness of the Neopixels to the data

Adjust the code so that if the accelerometer is tapped in the X direction, the Neopixel strip lights up green. If tapped in Y, Red, and tapped in Z, blue.

Solution