Overview
Get your cybergoth on with five color-changing NeoPixels studded onto a leather collar. The tiny GEMMA microcontroller can display endless animations on this fun funky accessory that's easy to make with a little soldering!
GEMMA jewelry! The bitty board fits perfectly in the center of a NeoPixel ring for flashy hoop earrings or a charming pendant. Read on to build your own!
Before you get started, follow the Gemma M0 guide or the Classic Introducing GEMMA guide
You will need:
- Gemma M0 or Trinket M0 - you can also use a classic Gemma
- through-hole NeoPixels
- leather collar or cuff
- 150mAh rechargeable lipoly battery and charger
- solderless breadboard and alligator clips for prototyping
- soldering iron and solder
- solid core or stranded wire (20 to 26 gauge)
- helping third hand tool
- pliers
- wire strippers
- flush diagonal cutters
- awl or other pointy tool to pierce leather
- sharp utility knife
- cutting mat
- ruler
- marking pen/pencil
- gaffer tape or other material to protect battery
- velcro tape to secure battery to collar
Page last edited May 06, 2014
Text editor powered by tinymce.
Circuit Diagram
You could easily add five more pixels for a total of ten for a more intensely studded look!
Page last edited May 06, 2014
Text editor powered by tinymce.
Prototype Circuit
If this is your first time using GEMMA, work through the Gemma M0 guide or the Classic Introducing GEMMA guide.
We recommend using the Gemma M0 and following the CircuitPython Code page for downloading the NeoPixel Library and NeoPixel_Punk_Collar using the flash drive feature.
The Arduino IDE can be used with the GEMMA M0 or older versions of the GEMMA. See the Arduino Code page for this project for details. Once you have it up and running (test the 'blink' sketch), then download and install the NeoPixel library.
Page last edited May 06, 2014
Text editor powered by tinymce.
Arduino Code
Installing Arduino libraries is a frequent stumbling block. If this is your first time, or simply needing a refresher, please read the All About Arduino Libraries tutorial.
If the library is correctly installed (and the Arduino IDE is restarted), you should be able to navigate through the “File” rollover menus as follows:
File→Sketchbook→Libraries→Adafruit_NeoPixel→strandtest
Connect up your NeoPixels in a solderless breadboard and use alligator clips to attach to GEMMA, referring to the circuit diagram if necessary.
You’ll need to change a few lines in the code regarding the data pin (1), type of pixels (RGB vs GRB), and number of pixels (5). The resulting (and slightly simplified) code is below:
// SPDX-FileCopyrightText: 2017 Mikey Sklar for Adafruit Industries
//
// SPDX-License-Identifier: MIT
#include <Adafruit_NeoPixel.h>
#define PIN 1
// Parameter 1 = number of pixels in strip
// Parameter 2 = Arduino pin number (most are valid)
// Parameter 3 = pixel type flags, add together as needed:
// NEO_KHZ800 800 KHz bitstream (most NeoPixel products w/WS2812 LEDs)
// NEO_KHZ400 400 KHz (classic 'v1' (not v2) FLORA pixels, WS2811 drivers)
// NEO_GRB Pixels are wired for GRB bitstream (most NeoPixel products)
// NEO_RGB Pixels are wired for RGB bitstream (v1 FLORA pixels, not v2)
Adafruit_NeoPixel strip = Adafruit_NeoPixel(5, PIN, NEO_RGB + NEO_KHZ800);
// IMPORTANT: To reduce NeoPixel burnout risk, avoid connecting
// on a live circuit... if you must, connect GND first. Minimize
// distance between Arduino and first pixel.
void setup() {
strip.begin();
strip.show(); // Initialize all pixels to 'off'
}
void loop() {
// Some example procedures showing how to display to the pixels:
colorWipe(strip.Color(255, 0, 0), 50); // Red
colorWipe(strip.Color(0, 255, 0), 50); // Green
colorWipe(strip.Color(0, 0, 255), 50); // Blue
rainbow(20);
rainbowCycle(20);
}
// Fill the dots one after the other with a color
void colorWipe(uint32_t c, uint8_t wait) {
for(uint16_t i=0; i<strip.numPixels(); i++) {
strip.setPixelColor(i, c);
strip.show();
delay(wait);
}
}
void rainbow(uint8_t wait) {
uint16_t i, j;
for(j=0; j<256; j++) {
for(i=0; i<strip.numPixels(); i++) {
strip.setPixelColor(i, Wheel((i+j) & 255));
}
strip.show();
delay(wait);
}
}
// Slightly different, this makes the rainbow equally distributed throughout
void rainbowCycle(uint8_t wait) {
uint16_t i, j;
for(j=0; j<256*5; j++) { // 5 cycles of all colors on wheel
for(i=0; i< strip.numPixels(); i++) {
strip.setPixelColor(i, Wheel(((i * 256 / strip.numPixels()) + j) & 255));
}
strip.show();
delay(wait);
}
}
// 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);
}
}
From the Tools→Board menu, select the device you are using:
- Adafruit Gemma M0
- Adafruit Trinket M0
- Adafruit Gemma 8 MHz
- Adafruit Trinket 8 MHz
Connect the USB cable between the computer and your device. The original Gemma (8 MHz) and Trinket (8 MHz) need the reset button pressed on the board, then click the upload button (right arrow icon) in the Arduino IDE. You do not need to press the reset on the newer Gemma M0 or Trinket M0.
When the battery is connected, you should get a light show from the LEDs. All your pixels working? Great! You can take apart this prototype and get ready to put the pixels in the collar. Refer to the NeoPixel Uberguide for more info.
Page last edited May 06, 2014
Text editor powered by tinymce.
CircuitPython Code
GEMMA M0 boards can run CircuitPython — a different approach to programming compared to Arduino sketches. In fact, CircuitPython comes factory pre-loaded on GEMMA M0. If you’ve overwritten it with an Arduino sketch, or just want to learn the basics of setting up and using CircuitPython, this is explained in the Adafruit GEMMA M0 guide.
Below is CircuitPython code that works similarly (though not exactly the same) as the Arduino sketch shown on a prior page. 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 “code.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 GEMMA M0 guide link above to prepare the board for CircuitPython.
# SPDX-FileCopyrightText: 2017 Limor Fried for Adafruit Industries
#
# SPDX-License-Identifier: MIT
import time
from rainbowio import colorwheel
import board
import neopixel
from digitalio import DigitalInOut, Direction
pixpin = board.D1
numpix = 5
led = DigitalInOut(board.D13)
led.direction = Direction.OUTPUT
strip = neopixel.NeoPixel(pixpin, numpix, brightness=1, auto_write=True)
def colorWipe(color, wait):
for j in range(len(strip)):
strip[j] = (color)
time.sleep(wait)
def rainbow_cycle(wait):
for j in range(255):
for i in range(len(strip)):
idx = int((i * 256 / len(strip)) + j)
strip[i] = colorwheel(idx & 255)
time.sleep(wait)
def rainbow(wait):
for j in range(255):
for i in range(len(strip)):
idx = int(i + j)
strip[i] = colorwheel(idx & 255)
time.sleep(wait)
while True:
colorWipe((255, 0, 0), .1) # red and delay
colorWipe((0, 255, 0), .1) # green and delay
colorWipe((0, 0, 255), .1) # blue and delay
rainbow(0.05)
rainbow_cycle(0.05)
This code requires the neopixel.py library. A factory-fresh board will have this already installed. If you’ve just reloaded the board with CircuitPython, create the “lib” directory and then download neopixel.py from Github.
Page last edited May 06, 2014
Text editor powered by tinymce.
Build Collar
Lay the collar flat and mark two more spots at one-inch increments on either side of the center mark.
Use a ruler to mark the top-bottom center line on the collar as well.
Pierce your NeoPixels through the collar with the flat sides all facing the same way (away from where the GEMMA will go).
Use small pieces of wire to make a continuous power bus, and do the same with ground.
Pierce these marked spots with the awl. Prepare three pieces of wire by stripping one end, then thread them through the holes in the leather.
Use a piece of Velcro tape to affix the battery to the collar right next to the GEMMA. We arranged GEMMA and the battery so the collar slack covers/protects them. The battery wire wraps around the collar once, then plugs into GEMMA. This is how you turn the collar off/on.
Page last edited May 06, 2014
Text editor powered by tinymce.
Wear it!
While the collar is pretty durable, use caution in heavy rainstorms or really sweaty dance parties-- remove and power down the collar if the circuit is going to get wet. Store your collar in the round, and don't shove it in your bag or it might get twisted or crushed, which could break the circuit.
#include <Adafruit_NeoPixel.h>
#define N_LEDS 5
#define PIN 1
Adafruit_NeoPixel strip = Adafruit_NeoPixel(N_LEDS, PIN, NEO_RGB + NEO_KHZ800);
void setup() {
strip.begin();
}
int pos = 0, dir = 1; // Position, direction of "eye"
void loop() {
int j;
// Draw 5 pixels centered on pos. setPixelColor() will clip any
// pixels off the ends of the strip, we don't need to watch for that.
strip.setPixelColor(pos - 1, 0x100000); // Dark red
strip.setPixelColor(pos , 0xFF3000); // Center pixel is brightest
strip.setPixelColor(pos + 1, 0x100000); // Dark red
strip.show();
delay(70);
// Rather than being sneaky and erasing just the tail pixel,
// it's easier to erase it all and draw a new one next time.
for(j=-2; j<= 2; j++) strip.setPixelColor(pos+j, 0);
// Bounce off ends of strip
pos += dir;
if(pos < 0) {
pos = 1;
dir = -dir;
} else if(pos >= strip.numPixels()) {
pos = strip.numPixels() - 2;
dir = -dir;
}
}
Page last edited May 06, 2014
Text editor powered by tinymce.