Acceleration Maps to Color with CircuitPython
Channel: Dave Briccetti
Date: 08/08/2019

I walk you through a program that maps Circuit Playground Express acceleration values to colors. x, y, and z acceleration components map to red, green and blue, respectively.

When the CPX is level, the lights are blue because there is no acceleration on x or y, but on z, gravity pulls at 9.81 meters per second per second (m/s²). When banking, the vertical (z) axis is no longer directly aligned with gravity, so the blue decreases, and red increases because gravity is now pulling more along the x axis. Similarly, when changing the pitch from level, we see blue change to green.

Code:
https://github.com/dcbriccetti/Adafruit_CircuitPython_CircuitPlayground/blob/tilting-arpeggios-update/examples/advanced_examples/circuitplayground_gravity_pulls_pixel.py