Need help determining why an if statement doesn't work.

Or rather, it DOES change, it just doesn’t have any affect. I can see in the serial monitor that waitTime is flopping between 1 and 10, but my timer is always stuck on 10. What am I doing wrong here?

My ultimate goal is to run rainbow() for x seconds and allBlack() for y seconds.

#include

FASTLED_USING_NAMESPACE

#define FRAMES_PER_SECOND 60
#define NUM_LEDS_PER_STRIP 10
CRGB leds[NUM_LEDS_PER_STRIP];
int waitTime = 1;

void setup() {
FastLED.addLeds<WS2811, 2>(leds, NUM_LEDS_PER_STRIP);
FastLED.addLeds<WS2811, 14>(leds, NUM_LEDS_PER_STRIP);
FastLED.addLeds<WS2811, 7>(leds, NUM_LEDS_PER_STRIP);
FastLED.addLeds<WS2811, 8>(leds, NUM_LEDS_PER_STRIP);
set_max_power_in_volts_and_milliamps(5, 500);
Serial.begin(9600);
}

// List of patterns to cycle through. Each is defined as a separate function below.
typedef void (*SimplePatternList)();
SimplePatternList gPatterns = { rainbow, allBlack };

uint8_t gCurrentPatternNumber = 0; // Index number of which pattern is current
uint8_t gHue = 0; // rotating “base color” used by many of the patterns

void loop()
{
// Call the current pattern function once, updating the ‘leds’ array
gPatternsgCurrentPatternNumber;
if ((gCurrentPatternNumber) % 2 == 0) { // Check to see if the pattern number is even and set waitTime to 10
waitTime = 10;
Serial.println(waitTime);
Serial.println(gCurrentPatternNumber);
}else{ // if it’s odd, set waitTime to 1
waitTime = 1;
Serial.println( “else” );
Serial.println(waitTime);
Serial.println(gCurrentPatternNumber);
}
/*if (waitTime == 1){ // check to see if waitTime is set to 1 and set it to 10 if it is
waitTime = 10;
Serial.print ("Wait Time is “);
Serial.println (waitTime);
}else{ // if waitTime is 10, set it to 1
waitTime = 1;
Serial.print(” Wait Time 2 is ");
Serial.println (waitTime);
*/

//Serial.println(gCurrentPatternNumber);

// send the ‘leds’ array out to the actual LED strip
FastLED.show();

// do some periodic updates
EVERY_N_MILLISECONDS( 20 ) { gHue++; } // slowly cycle the “base color” through the rainbow
EVERY_N_SECONDS( waitTime ) { nextPattern(); } // change patterns periodically
}

#define ARRAY_SIZE(A) (sizeof(A) / sizeof((A)[0]))

void nextPattern()
{
// add one to the current pattern number, and wrap around at the end
gCurrentPatternNumber = (gCurrentPatternNumber + 1) % ARRAY_SIZE( gPatterns);
}

void allBlack()
{
FastLED.clear();
// waitTime = 1;
}

void rainbow()
{
// FastLED’s built-in rainbow generator
fill_rainbow( leds, NUM_LEDS_PER_STRIP, gHue, 7);

}

[ and ] for code tags, not < and >
Good job for trying though.

"if statement doesn't work" - that's a meaningless question title.

Judging by the source code of FastLED library, you cannot use

EVERY_N_SECONDS( waitTime )

with changing waitTime and expect the timer to honor the changes. EVERY_N_SECONDS doesn't work that way.

Such timer will capture waitTime value from the very first time control passes over this EVERY_N_SECONDS line. It will use that captured value forever. Changing waitTime after that will not have any effect on the timer.

You want a timer with changing period - stop using this EVERY_N_SECONDS macro-gimmick and use CEveryNSeconds class directly. Change the period using its setPeriod method.