I'm using CircuitPython and the FancyLED library by Phil Burgess to make pretty animations for my armor. I'm using a "fire" palette for the bra and a "water" palette for the mermaid necklace. These color palettes are really easy to customize.

The Gemma M0 also works with Arduino or with Microsoft MakeCode, so if you prefer using one of those platforms, we have lots of tutorials and code samples in the Adafruit Learning System.

We need to do a bit of setup to get the Gemma M0 working with CircuitPython. Here's what's on this page:

  1. Install the latest version of CircuitPython on the board
  2. Install the necessary CircuitPython libraries
  3. Copy and update the Python code
  4. Save the code to your Gemma

Ready to start? Here we go!

Install CircuitPython

This guide tells you all you need to know about CircuitPython:


For now, I'll just cherry-pick the necessaries, but be sure to read through the guide to get all the nitty gritty details and troubleshooting tips.

Scroll down until you find the Gemma M0 board and click on it. Then click Download for the latest release. A file will download to your computer with a file extension of uf2.

Plug your Gemma into your computer with a USB cable. You may need to click or double-click the Reset button. The board will appear on your computer as a drive called GEMMABOOT. Drag the file you just downloaded onto this drive to install CircuitPython. The disk drive name GEMMABOOT will magically change to read CIRCUITPY.

Note: if you don't see GEMMABOOT, but instead see a drive called CIRCUITPY, that means CircuitPython is already installed. You probably want to follow the instructions to update CircuitPython to the latest version.

Install Libraries

Now we need to install a few libraries onto our board as well. Here's a guide that tells you all you'll ever want to know about installing libraries:


I'll just hit the highlights again to get you up and running.

The above button takes you to a page where you can download the latest library release. Click the big purple button to do so.

Now go to your CIRCUITPY drive and create a new folder called lib. Unzip the Library bundle and find:

  • adafruit_fancyled
  • neopixel.mpy

Drag these two folders/files into your brand new lib folder.

Upload the Code

The last thing we need to add is a file called code.py on the CIRCUITPY drive. This is where the Gemma will look for actual instructions on what to do. Copy the code below into a text or code editor -- we recommend the Mu editor which can be downloaded here.

""" Simple FancyLED example for NeoPixel strip

import board
import neopixel
import adafruit_fancyled.adafruit_fancyled as fancy

num_leds = 17

# Declare a Water Colors palette
palette = [fancy.CRGB(0, 214, 214), # blues and cyans
           fancy.CRGB(0, 92, 160),
           fancy.CRGB(0, 123, 255),
           fancy.CRGB(0, 68, 214)]

# Declare a Fire Colors palette
#palette = [fancy.CRGB(0, 0, 0),       # Black
#             fancy.CHSV(1.0),           # Red
#              fancy.CRGB(1.0, 1.0, 0.0), # Yellow
#              0xFFFFFF]                  # White

# Declare a NeoPixel object on pin D6 with num_leds pixels, no auto-write.
# Set brightness to max because we'll be using FancyLED's brightness control.
pixels = neopixel.NeoPixel(board.D1, num_leds, brightness=1.0,

offset = 0  # Positional offset into color palette to get it to 'spin'

while True:
    for i in range(num_leds):
        # Load each pixel's color from the palette using an offset, run it
        # through the gamma function, pack RGB value and assign to pixel.
        color = fancy.palette_lookup(palette, offset + i / num_leds)
        color = fancy.gamma_adjust(color, brightness=0.25)
        pixels[i] = color.pack()

    offset += 0.02  # Bigger number = faster spin

Once you have the code in your editor, look near the top and find this line:

Download: file
num_leds = 17

Change this number to reflect the total number of lights you have in your strand. If you have multiple strands soldered to the same pin, just use the number in one of the strands -- for example, I've soldered two strands of 17 lights each to pin D1, and that still counts as 17 pixels, not 34, since they're running in sync with each other.

Customizing Palettes

I've added two different color palettes for the animations accessed from the Control Pad:  a "fire" and a "water" palette. You can customize these fairly easily in the code. The power of the FancyLED library allows you so much control when it comes to choosing custom colors and animating them smoothly.

Find the palette definitions in the code:

Download: file
# Declare a Water Colors palette
palette = [fancy.CRGB(0, 214, 214), # blues and cyans
           fancy.CRGB(0, 92, 160),
           fancy.CRGB(0, 123, 255),
           fancy.CRGB(0, 68, 214)]
# Declare a Fire Colors palette
#palette = [fancy.CRGB(0, 0, 0),       # Black
#             fancy.CHSV(1.0),           # Red
#              fancy.CRGB(1.0, 1.0, 0.0), # Yellow
#              0xFFFFFF]                  # White

Uncomment the last four lines of to use the Fire palette instead of the water palette. (Remember to comment out all the lines in the water palette declaration as well)

You can use CRGB values or CHSV values to choose colors, or use them both at the same time. There are also multiple ways to declare values and a lot of control over how spread out the gradients can be.

This is explained in detail in the FancyLED guide so take a look to find out all you need to know about creating your own custom color palettes.

Save the code on your CIRCUITPY drive, called code.py

That's it! 

This guide was first published on Sep 25, 2019. It was last updated on Sep 25, 2019.
This page (Software) was last updated on Mar 17, 2020.