I've got all my leds on one pin and I'm trying to fire on (then fade off) groups of them at a time, and when I (eventually) push a button, this rotation of 7 lights will go faster and faster and faster. Unfortunately right now even with no delays the speed isn't as fast as I would like.
How would I go about making them flash faster and faster each successive group?
#define PIN2 2
#define CYC_LED_NUM 28
Adafruit_NeoPixel cycloPins = Adafruit_NeoPixel(CYC_LED_NUM, PIN2, NEO_GRB + NEO_KHZ800);
void setup() {
cycloPins.begin();
cycloPins.show();
}
void loop() {
cycOnePin();
rotateLED();
}
void rotateLED(){
if(rotatenum < 3){
rotatenum++;
} else {
rotatenum=0;
}
}
void cycOnePin(){
switch (rotatenum) {
case 0: // light the first 7 lights (cyclo 1)
for(int i=0;i<=6;i++){
cycloPins.setBrightness(255);
cycloPins.setPixelColor(i, 255,0,0); // RED // setPixelColor(n, red, green, blue)
cycloPins.show();
}
for(int y=255;y>=0;y--){
cycloPins.setBrightness(y); // change the brightness for next time through the loop:
cycloPins.show();
//delay(2);
}
break;
case 1: // light the first 7 lights (cyclo 2)
for(int i=7;i<=13;i++){
cycloPins.setBrightness(255);
cycloPins.setPixelColor(i, 255,0,0); // RED // setPixelColor(n, red, green, blue)
cycloPins.show();
}
for(int y=255;y>=0;y--){
cycloPins.setBrightness(y); // change the brightness for next time through the loop:
cycloPins.show();
//delay(2);
}
break;
case 2: // light the first 7 lights (cyclo 3)
for(int i=14;i<=20;i++){
cycloPins.setBrightness(255);
cycloPins.setPixelColor(i, 255,0,0); // RED // setPixelColor(n, red, green, blue)
cycloPins.show();
}
for(int y=255;y>=0;y--){
cycloPins.setBrightness(y); // change the brightness for next time through the loop:
cycloPins.show();
//delay(2);
}
break;
case 3: // light the first 7 lights (cyclo 4)
for(int i=21;i<=27;i++){
cycloPins.setBrightness(255);
cycloPins.setPixelColor(i, 255,0,0); // RED // setPixelColor(n, red, green, blue)
cycloPins.show();
}
for(int y=255;y>=0;y--){
cycloPins.setBrightness(y); // change the brightness for next time through the loop:
cycloPins.show();
//delay(2);
}
break;
default:
// if nothing else matches, do the default; default is optional
break;
}
}