I just wanted to share a sketch that I made for the 16 pixel NeoPixel Ring earrings that I made from parts purchased here at Adafruit. I made the earrings for my wife and did an orange circular pattern for Halloween. Yesterday I made a new sketch with alternating red and green colors. Then I added a sparkly flash in a random pattern. The glow was way too bright so I used lower numbers for the colors. Here is a copy of the sketch for you to use.
Code: Select all
/*Random blinky NeoPixel Ring
Red and Green with a sparkle for Christmas
By fid */
#include <Adafruit_NeoPixel.h>
#define N_PIXELS 16
#define LED_PIN 0 //You might have to change this if you didn't use
// pin 0 on the Gemma.
int RandomBlinky = 0;
int Brightness = 60; // Brightness of the pixels is about 60%
// I ended up not using the Brightness variable.
int BlinkDelay = 15;
int i = 0;
Adafruit_NeoPixel strip = Adafruit_NeoPixel(16, LED_PIN, NEO_GRB +NEO_KHZ800);
void setup()
{
strip.begin();
//strip.setBrightness(Brightness); // I ended up not using this.
for (i = 0; i < N_PIXELS; i++) // I think this should set the alternating
{ // Red Green pattern
if (i % 2 == 0) //Divide by 2. If the remainder is 0 the color is Red.
{ // Otherwise, the color is Green.
strip.setPixelColor( i, 10, 0, 0); // Red - Yes, it is very dim.
strip.show();
}
else
{
strip.setPixelColor( i, 0, 10, 0); // Green - It is also dim.
strip.show();
}
}
} // end of setup()
void loop()
{
RandomBlinky = random(16); // Choose a random NeoPixel.
// set the random pixel to white
strip.setPixelColor( RandomBlinky, 35, 35, 35); //It's a dim White.
strip.show();
delay(BlinkDelay); //Let the White show for a little bit.
//Set the random pixel back to the color it was, Red or Green
if (RandomBlinky % 2 == 0)
{
strip.setPixelColor( RandomBlinky, 10, 0, 0);
strip.show();
}
else
{
strip.setPixelColor( RandomBlinky, 0, 10, 0);
strip.show();
}
delay(150); //Don't do another White blinky for a little bit.
// Use a lower number to make the blinks happen faster.
} // End of loop()
/*
Instead of doing the brightness using the "strip.setBrightness(Brightness);",
how about setting Red to 150, 0, 0 and Green to 0, 150, 0?
And set the sparkle to 200,200,200.
This way the flash of the sparkle will be brighter than the brightness of the
rest of the colors on the ring.
Well, that was too bright. I used lower numbers for the colors in the sketch.
*/
Peace,
fid