NeoPixel GEMMA Mask

In addition to the supplies listed on the first page, you will need:

You should also check out the following prerequisite guides:

and optionally take a look at these projects with nearly identical circuits:

Use sewing pins to arrange and mock up your design on your mask. Use the circuit diagram below, adding or subtracting NeoPixels to suit your own design.

Wire connections are as follows:

  • GEMMA Vout connects to the (+) side of your NeoPixels
  • GEMMA D1 connects to the data input of the first pixel
  • data output of each pixel connects to data input of next pixel
  • GEMMA GND connects to the (-) side of all NeoPixels
  • 150mAh (or larger if you prefer) battery plugs in to GEMMA JST port

To ensure you have enough wire slack between pixels for your design, it can be helpful to first solder the data connections, then add the power and ground connections with the circuit in its rough orientation. Don't forget that the power and ground connections need two wires connected at a time, which is easier to do at once instead of separately!

Arduino Code

(CircuitPython code appears further down this page)

Once soldered, plug in your GEMMA to your computer over USB and program it up with the following sample code or any NeoPixel designs you like! Remember that GEMMA's power switch must be in the ON position!

#include <Adafruit_NeoPixel.h>

#define NUM_LEDS 5 // Number of NeoPixels
#define PIN 1      // DIGITAL pin # where NeoPixels are connected

// IMPORTANT: Avoid connecting on a live circuit...
// if you must, connect GND first.

Adafruit_NeoPixel strip = Adafruit_NeoPixel(NUM_LEDS, PIN);

void setup() {
  strip.begin();
  strip.setBrightness(100); // 100/255 brightness (about 40%)
  strip.show();             // Initialize all pixels to 'off'
}

void loop() {
  for(int j=0; j<256; j++) {
    for(int i=0; i<NUM_LEDS; i++) {
      strip.setPixelColor(i, Wheel((i * 8 + j) & 255));
    }
    strip.show();
    delay(20);
  }
}

// Input a value 0 to 255 to get a color value.
// The colours are a transition r - g - b - back to r.
uint32_t Wheel(byte WheelPos) {
  if(WheelPos < 85) {
    return strip.Color(WheelPos * 3, 255 - WheelPos * 3, 0);
  } else if(WheelPos < 170) {
    WheelPos -= 85;
    return strip.Color(255 - WheelPos * 3, 0, WheelPos * 3);
  } else {
    WheelPos -= 170;
    return strip.Color(0, WheelPos * 3, 255 - WheelPos * 3);
  }
}

CircuitPython Code

Below is CircuitPython code that works similarly to the Arduino sketch shown above. To use this, plug the GEMMA M0 into USB…it should show up on your computer as a small flash drive…then edit the file “main.py” with your text editor of choice. Select and copy the code below and paste it into that file, entirely replacing its contents (don’t mix it in with lingering bits of old code). When you save the file, the code should start running almost immediately (if not, see notes at the bottom of this page).

If GEMMA M0 doesn’t show up as a drive, follow the Introducing GEMMA M0 guide link above to prepare the board for CircuitPython.

import time

import board
import neopixel

numpix = 5  # Number of NeoPixels
pixpin = board.D1  # Pin where NeoPixels are connected
hue = 0  # Starting color
strip = neopixel.NeoPixel(pixpin, numpix, brightness=0.4)


def wheel(pos):
    # Input a value 0 to 255 to get a color value.
    # The colours are a transition r - g - b - back to r.
    if (pos < 0) or (pos > 255):
        return [0, 0, 0]
    elif pos < 85:
        return [int(pos * 3), int(255 - (pos * 3)), 0]
    elif pos < 170:
        pos -= 85
        return [int(255 - pos * 3), 0, int(pos * 3)]
    else:
        pos -= 170
        return [0, int(pos * 3), int(255 - pos * 3)]


while True:  # Loop forever...
    for i in range(numpix):
        strip[i] = wheel((hue + i * 8) & 255)
    strip.write()
    time.sleep(0.02)  # 20 ms = ~50 fps
    hue = (hue + 1) & 255  # Increment hue and 'wrap around' at 255

Once you've verified your circuit works, glue it up to your mask and route the GEMMA wires around to the back.

Use more glue or foam/velcro tape to put GEMMA in place.

Velcro tape is best for securing the battery, so that you can remove it for charging (GEMMA does not have onboard lipoly charging for your safety).

Use clear or color-coordinging thread to tack the wires to the mask for a clean finish.

You can optionally use 3D printed diffusers to deck out your NeoPixels even further! Browse our Thingiverse page for multiple available designs.

Learn more in our NinjaFlex guide.

This guide was first published on Sep 23, 2015. It was last updated on Sep 23, 2015. This page (NeoPixel GEMMA Mask) was last updated on Apr 25, 2019.