NeoPixels are a revolutionary and ultra-popular way to add lights and color to your project. These full-color RGB lights have the controller inside the LED, so you can just push the RGB data to your device and the LEDs do all the work for you. So they are programmable!

The Circuit Playground Express has 10 of these NeoPixels, arranged in a circular pattern:


Inside each NeoPixel, there are three tiny LEDs: Red, Green, and Blue:


Each LED is controlled by the circuit next to it, which acts like a brain. This is what receives the NeoPixel commands and actually turns on/off the LEDs. RGB can be combined in various proportions to obtain any color in the visible spectrum.

To do so, we would first need this line of code to access the cpx module:

from adafruit_circuitplayground.express import cpx

The cpx stands for Circuit Playground Express.

All the NeoPixels can be lit to the same color value specified using the cpx.pixels.fill() function. And the color that we want can go inside the parentheses.

Colors are stored as tuples by default. The values are (red, green, blue), and each value can range from 0-255 (fully off to fully on).

So to turn all the NeoPixels red (255, 0, 0):

cpx.pixels.fill( (255, 0, 0) )

Because the color values are wrapped in parentheses, too, there are now a double parentheses.

And to turn all the NeoPixels red “forever”:

while True: cpx.pixels.fill( (255, 0, 0) )

This uses an infinite while loop that repeatedly executes the code inside over and over again.

Note: There is an indentation (2 spaces) inside the while loop.



In this exercise, we are going to light up the Circuit Playground Express!

First things first, let’s import the module that we need in code.py:

from adafruit_circuitplayground.express import cpx

Then, run the code.


To make it light up “forever”, we will need a while loop that will never end:

while True:

And inside the while loop…

Use W3School’s Color Picker and find your favorite color.

Turn all the NeoPixels into your favorite color using the cpx.pixels.fill() function.


Click the Download button to download the code.py file.

Drag and drop the downloaded file into the CIRCUITPY drive on your computer.

It should look like this:

File Icons

Wait two seconds and the colors should show up!

code.py is a Python file that controls the Circuit Playground Express. We are going to continue to change this file in this course.

Press Run again when you are ready to move on.

Sign up to start coding

Mini Info Outline Icon
By signing up for Codecademy, you agree to Codecademy's Terms of Service & Privacy Policy.

Or sign up using:

Already have an account?