I'm using the NeoPixel Ring from Adafruit and trying to pulse though and array of colors. However, I'm having trouble with having the loop go to the next color at the end of each pulse (end of loop). Here is what I currently have:
uint32_t color[] = {red, green, blue,yellow,teal,magenta};
void pulseUp(uint8_t speed){
int fadeAmount = 10; //how much to increase each loop
int n = 0; //get first color
for(int b = 100; b >= 10; b = b - fadeAmount) { //start pulse for loop
for (int i = 0; i < strip.numPixels(); i++) { //select all pixels
strip.setPixelColor(i, color[n]); //set color from our array
}
strip.setBrightness(b); //set brightness based on b
strip.show(); // send the changes to the strip
delay(speed); //wait before running again
//if at the end of the loop (brightness is 10) change color
if (b == 10){
if( n > 6){ //if we are at last color in our loop start over
n = 0;
}
else{
n++; //auto increment color value
}
}
}
}
I'm sure the problem is with the if statements but not sure how to fix it.
ifstatement andn++instead of a loop. – Brooke. Sep 07 '15 at 21:18ifis not a looping statement. – Ignacio Vazquez-Abrams Sep 07 '15 at 21:19