// NeoPixel test program showing use of the WHITE channel for RGBW
// pixels only (won't look correct on regular RGB NeoPixel strips).
#include <Adafruit_NeoPixel.h>
// Which pin on the Arduino is connected to the NeoPixels?
// On a Trinket or Gemma we suggest changing this to 1:
#define LED_PIN 6
// How many NeoPixels are attached to the Arduino?
#define LED_COUNT 16
// NeoPixel brightness, 0 (min) to 255 (max)
#define BRIGHTNESS 255 // Set BRIGHTNESS to about 1/5 (max = 255)
#define att 20
#define delta 2
#define delta2 30
int pos=-1;
int k=0;
// Declare our NeoPixel strip object:
// Adafruit_NeoPixel strip(LED_COUNT, LED_PIN, NEO_GRB + NEO_KHZ800);
Adafruit_NeoPixel strip = Adafruit_NeoPixel(LED_COUNT+1, LED_PIN, NEO_GRB + NEO_KHZ800);
// Argument 1 = Number of pixels in NeoPixel strip
// Argument 2 = Arduino pin number (most are valid)
// Argument 3 = Pixel type flags, add together as needed:
// NEO_KHZ800 800 KHz bitstream (most NeoPixel products w/WS2812 LEDs)
// NEO_KHZ400 400 KHz (classic 'v1' (not v2) FLORA pixels, WS2811 drivers)
// NEO_GRB Pixels are wired for GRB bitstream (most NeoPixel products)
// NEO_RGB Pixels are wired for RGB bitstream (v1 FLORA pixels, not v2)
// NEO_RGBW Pixels are wired for RGBW bitstream (NeoPixel RGBW products)
void setup() {
// These lines are specifically to support the Adafruit Trinket 5V 16 MHz.
// Any other board, you can remove this part (but no harm leaving it):
// END of Trinket-specific code.
strip.begin(); // INITIALIZE NeoPixel strip object (REQUIRED)
strip.clear();
strip.show(); // Turn OFF all pixels ASAP
strip.setBrightness(BRIGHTNESS);
for(int j=0; j<=255; j=j+delta) {
//for(int i=0; i<LED_COUNT; i++) {
pos++;
if ( pos==LED_COUNT ) { pos=0; }
strip.setPixelColor(pos, strip.Color(j,j,j));
strip.setPixelColor(LED_COUNT, strip.Color(j,j,j));
if (j<255-delta2) {k=j+delta2;} else {k=j-delta2;}
// if (pos==LED_COUNT-1) {strip.setPixelColor(0, strip.Color(k,k,k));}
// else {strip.setPixelColor(pos+1, strip.Color(k,k,k));}
strip.show();
delay(att);
//}
// strip.show();
// delay(att);
}
for(int j=255; j>=0; j=j-delta) {
// for(int i=0; i<LED_COUNT; i++) {
pos++;
if ( pos==LED_COUNT ) { pos=0; }
strip.setPixelColor(pos, strip.Color(255,j,j));
strip.setPixelColor(LED_COUNT, strip.Color(255,j,j));
if (j<255-delta2) {k=j+delta2;} else {k=j-delta2;}
// if (pos==LED_COUNT-1) {strip.setPixelColor(0, strip.Color(255,k,k));}
// else {strip.setPixelColor(pos+1, strip.Color(255,k,k));}
strip.show();
delay(att);
// }
// strip.show();
// delay(att);
}
}
void loop() {
// Fill along the length of the strip in various colors...
for(int j=0; j<=255; j=j+delta) {
// for(int i=0; i<LED_COUNT; i++) {
pos++;
if ( pos==LED_COUNT ) { pos=0; }
strip.setPixelColor(pos, strip.Color(255,j,0));
strip.setPixelColor(LED_COUNT, strip.Color(255,j,0));
if (j<255-delta2) {k=j+delta2;} else {k=j-delta2;}
// if (pos==LED_COUNT-1) {strip.setPixelColor(0, strip.Color(255,k,0));}
// else {strip.setPixelColor(pos+1, strip.Color(255,k,0));}
strip.show();
delay(att);
// }
// strip.show();
// delay(att);
}
for(int j=255; j>=0; j=j-delta) {
// for(int i=0; i<LED_COUNT; i++) {
pos++;
if ( pos==LED_COUNT ) { pos=0; }
strip.setPixelColor(pos, strip.Color(j,255,0));
strip.setPixelColor(LED_COUNT, strip.Color(j,255,0));
if (j<255-delta2) {k=j+delta2;} else {k=j-delta2;}
// if (pos==LED_COUNT-1) {strip.setPixelColor(0, strip.Color(k,255,0));}
// else {strip.setPixelColor(pos+1, strip.Color(k,255,0));}
strip.show();
delay(att);
// }
// strip.show();
// delay(att);
}
for(int j=0; j<=255; j=j+delta) {
// for(int i=0; i<LED_COUNT; i++) {
pos++;
if ( pos==LED_COUNT ) { pos=0; }
strip.setPixelColor(pos, strip.Color(0,255,j));
strip.setPixelColor(LED_COUNT, strip.Color(0,255,j));
if (j<255-delta2) {k=j+delta2;} else {k=j-delta2;}
// if (pos==LED_COUNT-1) {strip.setPixelColor(0, strip.Color(0,255,k));}
// else {strip.setPixelColor(pos+1, strip.Color(0,255,k));}
strip.show();
delay(att);
// }
// strip.show();
// delay(att);
}
for(int j=255; j>=0; j=j-delta) {
// for(int i=0; i<LED_COUNT; i++) {
pos++;
if ( pos==LED_COUNT ) { pos=0; }
strip.setPixelColor(pos, strip.Color(0,j,255));
strip.setPixelColor(LED_COUNT, strip.Color(0,j,255));
if (j<255-delta2) {k=j+delta2;} else {k=j-delta2;}
// if (pos==LED_COUNT-1) {strip.setPixelColor(0, strip.Color(0,k,255));}
// else {strip.setPixelColor(pos+1, strip.Color(0,k,255));}
strip.show();
delay(att);
// }
// strip.show();
// delay(att);
}
for(int j=0; j<=255; j=j+delta) {
// for(int i=0; i<LED_COUNT; i++) {
pos++;
if ( pos==LED_COUNT ) { pos=0; }
strip.setPixelColor(pos, strip.Color(j,0,255));
strip.setPixelColor(LED_COUNT, strip.Color(j,0,255));
if (j<255-delta2) {k=j+delta2;} else {k=j-delta2;}
// if (pos==LED_COUNT-1) {strip.setPixelColor(0, strip.Color(k,0,255));}
// else {strip.setPixelColor(pos+1, strip.Color(k,0,255));}
strip.show();
delay(att);
// }
// strip.show();
// delay(att);
}
for(int j=255; j>=0; j=j-delta) {
// for(int i=0; i<LED_COUNT; i++) {
pos++;
if ( pos==LED_COUNT ) { pos=0; }
strip.setPixelColor(pos, strip.Color(255,0,j));
strip.setPixelColor(LED_COUNT, strip.Color(255,0,j));
if (j<255-delta2) {k=j+delta2;} else {k=j-delta2;}
// if (pos==LED_COUNT-1) {strip.setPixelColor(0, strip.Color(255,0,k));}
// else {strip.setPixelColor(pos+1, strip.Color(255,0,k));}
strip.show();
delay(att);
// }
// strip.show();
// delay(att);
}
}