// NeoPixel Ring simple sketch (c) 2013 Shae Erisson
// released under the GPLv3 license to match the rest of the AdaFruit NeoPixel library
#include <Adafruit_NeoPixel.h>
#ifdef __AVR__
#include <avr/power.h>
#endif
// On a Trinket or Gemma we suggest changing this to 1
#define PIN 10
// How many NeoPixels are attached to the Arduino?
#define NUMPIXELS 8
// When we setup the NeoPixel library, we tell it how many pixels, and which pin to use to send signals.
// Note that for older NeoPixel strips you might need to change the third parameter--see the strandtest
// example for more information on possible values.
Adafruit_NeoPixel pixels = Adafruit_NeoPixel(NUMPIXELS, PIN, NEO_GRB + NEO_KHZ800);
int delayval = 100; // delay for half a second
void setup() {
Serial.begin(9600);
// This is for Trinket 5V 16MHz, you can remove these three lines if you are not using a Trinket
#if defined (__AVR_ATtiny85__)
if (F_CPU == 16000000) clock_prescale_set(clock_div_1);
#endif
// End of trinket special code
pixels.begin(); // This initializes the NeoPixel library.
}
void iterate_pixels(uint32_t c)
{
for (int i = NUMPIXELS - 1; i >= 0; i--) {
// pixels.Color takes RGB values, from 0,0,0 up to 255,255,255
pixels.setPixelColor(i, c);
pixels.show(); // This sends the updated pixel color to the hardware.
delay(100); // Delay for a period of time (in milliseconds).
pixels.setPixelColor(i, 0);
pixels.show();
}// 1st For
pixels.clear();
pixels.show();
}
static uint32_t color_sequence[] = {
Adafruit_NeoPixel::Color(255, 0, 0),
Adafruit_NeoPixel::Color(0, 255, 0),
Adafruit_NeoPixel::Color(0, 0, 255),
Adafruit_NeoPixel::Color(255, 255, 0),
Adafruit_NeoPixel::Color(255, 0, 255),
Adafruit_NeoPixel::Color(0, 255, 255),
};
void loop() {
for (int i = 0; i < sizeof(color_sequence)/sizeof(color_sequence[0]); ++i) {
iterate_pixels(color_sequence[i]);
}
}