Accessing the onboard neopixels is easy to do.  There is some example code to get you started in the Circuit Playground library.  In Arduino, open:  

Examples > Adafruit Circuit Playground > Hello_CircuitPlayground > Hello_Neopixels

This code shows two different ways to send color data to your neopixels, and an easy way to blink them on and off.  Take a look  at these five lines:

  CircuitPlayground.setPixelColor(0, 255,   0,   0);
  CircuitPlayground.setPixelColor(1, 128, 128,   0);
  CircuitPlayground.setPixelColor(2,   0, 255,   0);
  CircuitPlayground.setPixelColor(3,   0, 128, 128);
  CircuitPlayground.setPixelColor(4,   0,   0, 255);

The first argument in each line -- in this case, 0-4 -- is the pixel number.  (The pixels are numbered 0-9, since counting that way makes computers unreasonably happy.)  When looking at the board with the USB port facing up, pixel 0 is located at 11:00, just to the left of the port.  You can light up any pixel by calling its pixel number here.  

The next three numbers correspond to values for red, green, and blue.  0 is off, and 255 is full brightness for that color.  The way neopixels work is by mixing different amounts of light from the red, green, and blue LEDs hidden inside each pixel.  Play with changing these numbers within a range of 0-255 to get the color you want.

  CircuitPlayground.setPixelColor(6, 0x808000);
  CircuitPlayground.setPixelColor(7, 0x00FF00);
  CircuitPlayground.setPixelColor(8, 0x008080);
  CircuitPlayground.setPixelColor(9, 0x0000FF);

The next 5 lines show a slightly different way to set the color.  The first argument still corresponds to the pixel number, and the next part is a Hexidecimal code -- you can always recognize these because you'll see the prefix "0x".

Hex codes are an easy way to get any color you want.  Look for online color pickers or desktop widgets to make your life easy.  However, the colors will not always look the same on your neopixels as they do on your screen, especially with darker colors, so be ready for some experimentation.

These are just a couple of quick ways to get your lights up and running.  Neopixels are also wonderful for running animations or reacting to some of the Circuit Playground's onboard sensors.  Here are a few other guides and code samples that are fun to play with.

Code Samples

You'll also find a lot more samples to play with in the Examples folder in the Circuit Playground library, including vu_meter which lights up the pixels in response to sound.   

Here's one more sample that gently animates the pixels in a rainbow or one of several other color palettes.  The left button will change modes and the right button will turn the LEDs off.

NOTE:  You will need to install the FastLED library in Arduino first (Sketch > Include Library > Manage Libraries...)

One other note:  if you're using FastLED with Circuit Playground, be sure to include the Circuit Playground library FIRST and the FastLED library second, or you may run into problems.

#include <Adafruit_CircuitPlayground.h>
#include <FastLED.h>

#define LED_PIN     17
#define NUM_LEDS    10

int BRIGHTNESS =255;
int STEPS      =25;
int NUM_MODES   =5;


CRGBPalette16 currentPalette;
TBlendType    currentBlending;

int ledMode = 0;
bool leftButtonPressed;
bool rightButtonPressed;

void setup() {
  FastLED.addLeds<WS2812B, LED_PIN, COLOR_ORDER>(leds, NUM_LEDS).setCorrection( TypicalLEDStrip );
  currentBlending = LINEARBLEND;


void loop()  {

  leftButtonPressed = CircuitPlayground.leftButton();
  rightButtonPressed = CircuitPlayground.rightButton();

  if (leftButtonPressed) {
    if (ledMode > NUM_MODES){
    if (rightButtonPressed) {
 switch (ledMode) {
       case 0: currentPalette = RainbowColors_p; rainbow(); break; 
       case 1: currentPalette = OceanColors_p; rainbow(); break; 
       case 2: currentPalette = ForestColors_p; rainbow(); break;                      
       case 3: currentPalette = PartyColors_p; rainbow(); break; 
       case 4: currentPalette = HeatColors_p; rainbow(); break; 
       case 5: currentPalette = RainbowStripeColors_p; rainbow(); break;    
       case 99: CircuitPlayground.clearPixels(); break;
void rainbow()
  static uint8_t startIndex = 0;
  startIndex = startIndex + 1; /* motion speed */

  FillLEDsFromPaletteColors( startIndex);;

//this bit is in every palette mode, needs to be in there just once
void FillLEDsFromPaletteColors( uint8_t colorIndex)
  uint8_t brightness = BRIGHTNESS;
  for( int i = 0; i < NUM_LEDS; i++) {
    leds[i] = ColorFromPalette( currentPalette, colorIndex, brightness, currentBlending);
    colorIndex += STEPS;
Last updated on 2017-02-21 at 07.54.10 PM Published on 2017-02-21 at 05.28.05 PM