Usually you wait until the end of the project to do the programming. In this case, this is the best way to make sure your parts are working before you glue them down. Connect your GEMMA to your computer with the cable and upload the following code. Notice the section with the colors--you can hack that to be any combination you like. I found that deeper colors work better than lighter ones, but it can be fun to have a subtle mix.
// SPDX-FileCopyrightText: 2017 Leslie Birch for Adafruit Industries // // SPDX-License-Identifier: MIT /* Jewel Hairstick by Leslie Birch for Adafruit Industries Based on NeoPixel Library by Adafruit */ // This section is NeoPixel Variables #include <Adafruit_NeoPixel.h> #define PIN 1 // Parameter 1 = number of pixels in strip // Parameter 2 = 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(7, 1, NEO_GRB + NEO_KHZ800); //You can have fun here changing the colors for the code uint32_t color1 = strip.Color(236, 79, 100); //Salmon Pink uint32_t color2 = strip.Color(246, 216, 180); //Cream uint32_t color3 = strip.Color(174, 113, 208); //Lavendar uint32_t color4 = strip.Color(182, 31, 40); //Red uint32_t color5 = strip.Color(91, 44, 86); //Purple void setup() { //This is for Neopixel Setup strip.begin(); strip.show(); // Initialize all pixels to 'off' } void loop() { strip.setBrightness(30); // the first number is the pixel number for Jewel. O is the center one strip.setPixelColor(1, color1); strip.setPixelColor(2, color1); strip.setPixelColor(3, color1); strip.setPixelColor(4, color1); strip.setPixelColor(5, color1); strip.setPixelColor(6, color1); strip.setPixelColor(0, color2); strip.show(); delay(3000); strip.setPixelColor(1, color2); strip.setPixelColor(2, color2); strip.setPixelColor(3, color2); strip.setPixelColor(4, color2); strip.setPixelColor(5, color2); strip.setPixelColor(6, color2); strip.setPixelColor(0, color3); strip.show(); delay(3000); strip.setPixelColor(1, color3); strip.setPixelColor(2, color3); strip.setPixelColor(3, color3); strip.setPixelColor(4, color3); strip.setPixelColor(5, color3); strip.setPixelColor(6, color3); strip.setPixelColor(0, color4); strip.show(); delay(3000); strip.setPixelColor(1, color4); strip.setPixelColor(2, color4); strip.setPixelColor(3, color4); strip.setPixelColor(4, color4); strip.setPixelColor(5, color4); strip.setPixelColor(6, color4); strip.setPixelColor(0, color5); strip.show(); delay(3000); strip.setPixelColor(1, color5); strip.setPixelColor(2, color5); strip.setPixelColor(3, color5); strip.setPixelColor(4, color5); strip.setPixelColor(5, color5); strip.setPixelColor(6, color5); strip.setPixelColor(0, color1); strip.show(); delay(3000); }
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:
From the Tools→Board menu, select the device you are using:
- Adafruit Gemma M0
- Adafruit Gemma 8 MHz
- Connect the USB cable between the computer and your device. The original Gemma (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 January 18, 2025
Text editor powered by tinymce.