Here's a modified version of PhilB's larson scanner code, which chases back and forth across the collar. Use it as a jumping-off point, then code up your own crazy animations!

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() {

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;

  // 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;

This guide was first published on May 07, 2014. It was last updated on May 07, 2014.

This page (Wear it!) was last updated on May 06, 2014.

Text editor powered by tinymce.