First thing we need to do is install the project code. This code will use the Circuit Playground Express's built-in accelerometer to sense vibration and then light up the built in Neopixel LEDs.

Upload the Code

Connect the Circuit Playground Express to your computer with a micro USB cable.  You should see a drive named "CIRCUITPY" appear on your computer. 

You'll need to have the Neopixel library installed on your Circuit Playground Express in order to run this project's CircuitPython code. Follow the steps on this page to install the CircuitPython library bundle.

Copy the following code, paste it into a plain text file or code editor such as Mu. Save the file as "" to the CIRCUITPY drive.

# SPDX-FileCopyrightText: 2018 Collin Cunningham for Adafruit Industries
# SPDX-License-Identifier: MIT

import board
import neopixel
from import cpx

pixels = neopixel.NeoPixel(board.NEOPIXEL, 10, brightness=0.1, auto_write=True)

while True:

    x, y, z = cpx.acceleration  # read acceleromter
    r, g, b = 0, 0, 0

    if abs(x) > 4.0:
        r = 255
    if abs(y) > 2.0:
        g = 255
    if z > -6.0 or z < -12.0:
        b = 255

    pixels.fill((r, g, b))

After the file saves, your Circuit Playground Express should reboot and start running the action light code.

Here's what your CIRCUITPY drive should look like with necessary files in place.

Test It

To make sure everything is working, disconnect the Circuit Playground Express from your computer and connect the LiPo battery.

Try shaking the Circuit Playground around a bit.  If it flashes different colors - the code is working!

This guide was first published on May 02, 2018. It was last updated on Jun 23, 2024.

This page (Software) was last updated on Jun 22, 2024.

Text editor powered by tinymce.