#include <Adafruit_NeoPixel.h>
#define PIN 6
#define NUMPIXELS 16
Adafruit_NeoPixel ring = Adafruit_NeoPixel(NUMPIXELS, PIN, NEO_GRB + NEO_KHZ800);
void setup() {
// put your setup code here, to run once:
ring.begin();
ring.show();
}
void loop() {
// put your main code here, to run repeatedly:
rainbowCycle(5);
}
void rainbowCycle(int wait) {
uint16_t i, j;
for(j=0; j<256; j++) {
for(i=0; i<ring.numPixels(); i++) {
ring.setPixelColor(i, Wheel((i * 256 / ring.numPixels() + j) & 255));
}
ring.show();
delay(wait);
}
}
uint32_t Wheel(byte WheelPos) {
WheelPos = 255 - WheelPos;
if(WheelPos < 85) {
return ring.Color(255 - WheelPos * 3, 0, WheelPos * 3);
} else if(WheelPos < 170) {
WheelPos -= 85;
return ring.Color(0, WheelPos * 3, 255 - WheelPos * 3);
} else {
WheelPos -= 170;
return ring.Color(WheelPos * 3, 255 - WheelPos * 3, 0);
}
}