IMU

An inertial measurement unit, or IMU, is a MEMS device that reads the acceleration and angular velocity of a device. It can be used to measure motion, like step count, or which way is down, for screen orientation. Most IMUs use digital communication like serial called I2C or SPI to relate their data. The IMU in the kit is from Adafruit. Download and install the library from this github.

Connect the IMU

The IMU break needs 4 connections: 3.3V to VDD, ground to VSS, and the data pins, SDA to the Teensy SDA1 and SCL to the Teensy SCL1.

Plot the data

The IMU has many settings, but for simple use, include the library at the top of the code, initialize the IMU in setup(), and read the data with imu.read(). The values returned for acceleration range from -32000 to +32000, where +16000 is 1g of acceleration. -16000 is -1g, or completely downwards.

Make a new file and read the accelerometer data 30 times per second, printing the X Y and Z acceleration values in three columns separated by spaces. View the data with the serial plotter.

Image of IMU data IMU data on the serial plotter

Solution

Set the brightness of the Neopixels to the data

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

Solution