Code behaving oddly. No errors in compiling but warnings

Hello all. I am by no means a coder. I primarily do 3d printing of movie props and the such. My current project is an Avengers Stormbreaker that has 7 led light strips and an led ring inside to mimic lightening and other visual effects. The Code for the Arduino Nano was included with my STL files. When I verify I get several warnings but it will upload to the board. Once uploaded to the board I get odd behavior from the programs. Below is the coding. I can screen shot the warnings also. Thanks in advance for any help to resolve this issue.

#include <FastLED.h>
#include <stdio.h>
#include <stdlib.h>
#include <hsv2rgb.h>

#define PIN12 12
#define PIN11 11
#define PIN10 10
#define PIN9 9
#define PIN8 8
#define PIN7 7
#define PIN6 6
#define PIN5 5

#define MAX_STRIPS 8
#define MAX_LED_STRIP 30

#define LIGHTNING_PROB 450


#define COLOR_ORDER RGB
#define LED_TYPE WS2812B

int STATE = 0;
int lastStates[8] = {0, 0, 0, 0, 0, 0, 0, 0}; // 0: incandescent, 1: lightning, 2: burst
int time_stamp = 0;
int buttonKnob = 0;
int burstStage = 0;
int pace = 60;
int burstOption = 0;
int lastState = 0;
int ticksExplode = 0;
bool burstToIdle = false;


uint8_t max_brightness = 255;
CRGB leds[MAX_STRIPS][MAX_LED_STRIP];

void lightning(int strip, int maxlength, int probability);
void incandescentYellow(int strip, int maxlength);
void incandescentRed(int strip, int maxlength);
void incandescent();
void lightningIdle();
void burst();
void gatherForBurst(int strip);
void prepareForBurst(int strip);
void explode(int strip);
void off();
void turnOff(int strip);
void stillIncandescent();
void red(int strip);

void setup() {
  // put your setup code here, to run once:
  Serial.begin(9600);
  delay(1000); // sleep for one second, to give you time to do a pose
  pinMode(buttonKnob, INPUT);

  LEDS.addLeds<LED_TYPE, PIN8, COLOR_ORDER>(leds[0], 12);// We are telling FastLed that we have a 15 LED strip of the type WS2812B connected to pin 12
  LEDS.addLeds<LED_TYPE, PIN5, COLOR_ORDER>(leds[1], 18);
  LEDS.addLeds<LED_TYPE, PIN11, COLOR_ORDER>(leds[2], 18);
  // Hammer head LEDs
  LEDS.addLeds<LED_TYPE, PIN10, COLOR_ORDER>(leds[3], 16); // Hammer head bottom
  LEDS.addLeds<LED_TYPE, PIN6, COLOR_ORDER>(leds[4], 16); // Hammer head top
  LEDS.addLeds<LED_TYPE, PIN12, COLOR_ORDER>(leds[5], 10); // Hammer head left
  LEDS.addLeds<LED_TYPE, PIN9, COLOR_ORDER>(leds[6], 10); // Hammer head right
  LEDS.addLeds<LED_TYPE, PIN7, COLOR_ORDER>(leds[7], 24); // Hammer head ring
  
  FastLED.setBrightness(max_brightness);
}

void burst() {
  switch (burstStage) {
    case 0:
      gatherForBurst(0);
      lastStates[0] = 2;
      break;
    case 1:
      prepareForBurst(0);
      break;
    case 2:
      explode(0, 100);
      explode(1, 100);
      explode(2, 100);
      explode(3, 100);
      explode(4, 100);
      explode(5, 100);
      delay(1000/60);
      break;
    case 3:
      burstToIdle = true;
      STATE = 3;
      break;
  }
  
}

void gatherForBurst(int strip) {
  //CRGB dimmedWhite(5,5,5);
  //fill_solid(leds[strip], sizeof(leds[strip]), dimmedWhite);
  for (int i = 14 - 1; i >= 0; i--) {
    CHSV color = rgb2hsv_approximate(leds[strip][i]);
    if(lastStates[strip] != 2){
       leds[0][i].setRGB(97, 63, 169); // Turn all the LED strip to a soft blue
       leds[1][i].setRGB(97, 63, 169); // Turn all the LED strip to a soft blue
       leds[2][i].setRGB(97, 63, 169); // Turn all the LED strip to a soft blue
        Serial.println("Soft blue");
        FastLED.show();
        if (i >= 18 - 1) {
          pace = pace - 30;
        }
        if (i <= 5) {
          pace = pace + 30;
        }
    }
    else if(leds[strip][i].blue == 0 || i == sizeof(leds[strip]) - 1){ // if it's ready for a flash
      leds[strip][i].setRGB(200, 200, 255); // Flash
      if(i - 1 > 0){ // Prepare for flash
        leds[0][i].setRGB(0, 0, 0);
        leds[1][i].setRGB(0, 0, 0);
        leds[2][i].setRGB(0, 0, 0);
        Serial.println("Preparing");
        FastLED.show();
      }
      if (i >= 18 - 1) {
        pace = pace - 30;
      }
      if (i <= 5) {
        pace = pace + 30;
      }
    }
    else if(leds[strip][i].blue <= 255){ // If the led just flashed
      leds[0][i].setHSV(color.h, color.s, color.v - 15);
      leds[1][i].setHSV(color.h, color.s, color.v - 15);
      leds[2][i].setHSV(color.h, color.s, color.v - 15);
      leds[3][i].setHSV(color.h, color.s, color.v - 15);
      leds[4][i].setHSV(color.h, color.s, color.v - 15);
      leds[5][i].setHSV(color.h, color.s, color.v - 15);
      leds[6][i].setHSV(color.h, color.s, color.v - 15);
      leds[7][i].setHSV(color.h, color.s, color.v - 15);
      pace = 360;
      FastLED.show();
      Serial.println("Dimming");
      //Serial.println(color.v);
      if (color.v - 25 <= 50 && i == 1) {
        ticksExplode = 0;
        burstStage = 2;
        Serial.println(pace);
      }
    }
    
    if(i > 0)
      delay(1000/pace);
  }
  
}

void prepareForBurst(int strip) {
  Serial.println("Preparing for burst");
  for (int i = 0; i < sizeof(leds[strip]); i++) {
    CHSV color = rgb2hsv_approximate(leds[strip][i]);
    leds[strip][i].setHSV(208, 50, color.v - 5);
    Serial.println("Fading to dim white");
    if (color.v - 5 <= 15)
      burstStage = 2;

  }
}

void explode(int strip, int probability){
  Serial.println("EXPLODE");
   for (int i = 0; i < sizeof(leds[strip]); i++) {
    CHSV color = rgb2hsv_approximate(leds[strip][i]);
    int flash = rand() % probability; // 1 out of 50
    if (flash == 2) {
      // we get it ready for a flash. Principle of anticipation.
      //leds[strip][i].setRGB(44, 66, 127);
      CRGB flash = CRGB(200, 200, 255);
      fill_solid(leds[strip], sizeof(leds[strip]), flash);
      //Serial.println("GETREADY");
    }
    // We check the state of that LED
    if(leds[strip][i].red == 200 && leds[strip][i].blue == 255) { // If the LED just flashed a moment ago
      
      leds[strip][i].setHSV(213, 100, 100); // We fade it to blue
    } else if (leds[strip][i].blue <= 255) {
      //if(rand()%10 == 1)
        leds[strip][i].setHSV(213, 100, color.v - 1);
      //leds[strip][i].setRGB(leds[strip][i].red - 40, leds[strip][i].green - 40, leds[strip][i].blue--); // Keep fading down
      //Serial.println("KEEP FADING TO BLUE");
      if(color.v <= 80) { 
        leds[strip][i].setHSV(213, 100, 80);
        if(rand()%60 == 1){
          if(color.v < 80 && color.v > 0){
            if(rand()%2 == 1){
              leds[strip][i].setHSV(213, 100, color.v - 1);
            }
            else{
              leds[strip][i].setHSV(213, 100, color.v + 1);
            }
          }
        }
      }
      
    } 
    lastStates[strip] = 2;
    ticksExplode++;
    if(ticksExplode >= 10000){
      burstStage = 3;
    }
  }
  FastLED.show();
}

/*
   Function ligthningIdle. It calls lightning on all of the LED strips
   Params:
*/
void lightningIdle() {
  // Reset the timestamp
  burstStage = 0;
  // Here we call the lightning on all our LED Strips
  lightning(0, 12, 200);
  lightning(1, 18, 200);
  lightning(2, 18, 200);

  lightning(3, 16, 200);
  lightning(4, 16, 200);
  lightning(5, 10, 200);
  lightning(6, 10, 200);
  lightning(7, 24, 200);

  /*

    lightning(&B, NUM_LEDS_B);
    lightning(&C NUM_LEDS_C);
    lightning(&D, NUM_LEDS_D);
    lightning(&E, NUM_LEDS_E);
    lightning(&F, NUM_LEDS_F);
    lightning(&G, NUM_LEDS_G);
    lightning(&H, NUM_LEDS_H);
  */

  delay(1000 / 30);
}

/*
   Function incandescent. It calls incandescentYellow and Red depending on the strip
   Params:
*/
void incandescent() {
  burstStage = 0;
  incandescentRed(0, 12);
  incandescentYellow(1, 18);
  incandescentRed(2, 18);
  incandescentRed(3, 16);
  incandescentRed(4, 16);
  incandescentYellow(5, 10);
  incandescentYellow(6, 10);
  incandescentRed(7, 24);
  
  
  delay(1000 / 120);
}

/*
   Function ligthning. It calls the lightning animation on a single LED strip
   Params: strip. It's the number of the LED strip. Meaning, we can call this function with any of the strips we have and it will work. * means it's a pointer to the first LED of the strip
            maxlength. the size of the LED strip
*/

void lightning(int strip, int maxlength, int probability) {
  // We loop through the LED strip
  /*
     BLUE: 80, 150, 220 - 130, 180, 230
     GET READY: 44, 66, 127
     FLASH: 255, 255, 255
  */
  //fill_solid(leds[strip], maxlength, CRGB::White);
  for (int i = 0; i < maxlength; i++) {
    // Prepare random for a flash
    if (leds[strip][i].blue == 0){
      if(rand()%probability == 1)
        leds[strip][i].setRGB(0, 0, 0);
    }
    CHSV color = rgb2hsv_approximate(leds[strip][i]);
    int flash = rand() % probability; // 1 out of 50
    if (flash == 2) {
      // we get it ready for a flash. Principle of anticipation.
      //leds[strip][i].setRGB(44, 66, 127);
      leds[strip][i].setRGB(0, 0, 0);
      //Serial.println("GETREADY");
    }
    // We check the state of that LED
    if (leds[strip][i].red == 0 && leds[strip][i].blue == 0) { // If the LED is ready for a flash
      leds[strip][i].setRGB(255, 255, 255); // We make it flash white
      
      if (i + 1 < maxlength)
        leds[strip][i + 1].setRGB(194, 132, 248);// And the next 2 LEDs too
      if (i - 1 < maxlength)
        leds[strip][i -1].setRGB(194, 132, 248); // And the next 2 LEDs too
    } else if (leds[strip][i].red == 255 && leds[strip][i].blue == 255 || leds[strip][i].blue == 248 || burstToIdle == true) { // If the LED just flashed a moment ago
      //Serial.println("FADE TO BLUE");
      leds[strip][i].setHSV(190, 100, 100); // We fade it to blue
    } else if (leds[strip][i].blue <= 255) {
      //if(rand()%10 == 1)
        leds[strip][i].setHSV(190, 100, color.v - 1);
      //leds[strip][i].setRGB(leds[strip][i].red - 40, leds[strip][i].green - 40, leds[strip][i].blue--); // Keep fading down
      //Serial.println("KEEP FADING TO BLUE");
      if(color.v <= 80) { 
        leds[strip][i].setHSV(190, 100, 80);
        if(rand()%60 == 1){
          if(color.v < 80 && color.v > 0){
            if(rand()%2 == 1){
              leds[strip][i].setHSV(190, 100, color.v - 1);
            }
            else{
              leds[strip][i].setHSV(190, 100, color.v + 1);
            }
          }
        }
      }
      
    } else { // If it was in the incandescent state, transition into lightning by maybe getting ready
     
    }
    //FastLED.show();
    //delay(1000/120);
  }
  lastStates[strip] = 1;
  FastLED.show();
}

void incandescentYellow(int strip, int maxlength) {
  /*
     Colours:
     - Bright Yellow: 255, 255, 0
     - Dark orange: 255, 50, 0
     - Bright orange: 255, 100, 0
  */
  //fill_solid(leds[strip], maxlength, CRGB::Red);
  // First, glow everything to bright yellow
  
   for (int i = 0; i < maxlength; i++) {
    if (leds[strip][i].blue > 0) {
      leds[strip][i].setRGB(1, 30, 0);
    }
    if (leds[strip][i].red == 0) {
      leds[strip][i].setRGB(1, 30, 0);
      //Serial.println("Init");
    } else if (leds[strip][i].red >= 1 && leds[strip][i].red < 255) {
     
      Serial.println(leds[strip][i].red);
      //Serial.println(color.hue);
      leds[strip][i].setRGB(leds[strip][i].red + 1, leds[strip][i].green + 1, 0); // We add up a little bit of red and green light (yellow)
    }
    if (leds[strip][i].red >= 30) {
      leds[strip][i].red = 30;
    }
  }
  
  lastStates[strip] = 0;
  FastLED.show();
}
void red(int strip) {
  /*
     Colours:
     - Bright Yellow: 255, 255, 0
     - Dark orange: 255, 50, 0
     - Bright orange: 255, 100, 0
  */  
  //fill_solid(leds[strip], maxlength, CRGB::Red);

  for (int i = 0; i < sizeof(leds[strip]); i++) {
    leds[strip][i].setRGB(1, 30, 0);
   }
  
  FastLED.show();
  lastStates[strip] = 0;
}
void incandescentRed(int strip, int maxlength) {
  /*
     Colours:
     - Bright Yellow: 255, 255, 0
     - Dark orange: 255, 50, 0
     - Bright orange: 255, 100, 0
  */  
  //fill_solid(leds[strip], maxlength, CRGB::Red);

   for (int i = 0; i < maxlength; i++) {
    if (leds[strip][i].blue > 1) {
      if(rand()%2 == 0){
        leds[strip][i].setRGB(1, 30, 0);
      }
      else{
        leds[strip][i].setRGB(1, 30, 1);
      }
    }
    if (leds[strip][i].red == 0) {
       if(rand()%4 == 0){
        leds[strip][i].setRGB(1, 30, 1);
      }
      else{
        leds[strip][i].setRGB(1, 30, 0);
      }
      //Serial.println("Init");
    } else if (leds[strip][i].red >= 1 && leds[strip][i].red < 255) {
      int red = leds[strip][i].red;Serial.println("blue");
      red = red + 1;
      if(leds[strip][i].blue == 1){
         Serial.println("blue");
        leds[strip][i].setRGB(red, leds[strip][i].green + 1, 1); // We add up a little bit of red and green light (yellow)
      }
      else{
        //leds[strip][i].setRGB(red, leds[strip][i].green + 1, 0); // We add up a little bit of red and green light (yellow)
      }
      //
    }
    if (leds[strip][i].red >= 20) {
       leds[strip][i].red = 20;
    }
  }
  FastLED.show();
  lastStates[strip] = 0;
}
void stillIncandescent(){
  red(0);
  incandescentYellow(1, 18);
  red(2);
  red(3);
  red(4);
  incandescentYellow(5, 10);
  incandescentYellow(6, 10);
  red(7);
  delay(1000/30);
}
void turnOff(int strip){
  
  fill_solid(leds[strip], sizeof(leds[strip]), CRGB::Black);
  
}
void off(){
   for(int i = 0; i < MAX_STRIPS - 1; i++){
    turnOff(i);
  }
}

void loop() {
  // He we have our Finite State Machine (the brain of the Stormbreaker where we will send our animation request using the potentiometer (knob)
  // First we read the input from the knob, which is the voltage and we transform it to a state
   time_stamp++;
   lastState = STATE;
   
    int val = analogRead(1);
    if (val >= 0 && val <= 255) {
     STATE = 0;
    }
    else if (val > 255 && val <= 512) {
     STATE = 1;
    }
    else if (val > 512 && val <= 768) {
     STATE = 2;
    }
     else if (val > 768 && val <= 1024) {
     STATE = 3;
    }

    if(burstToIdle == true){
      STATE = 3;
    }
     
  //lightningIdle();
  // Then we run our state machine
  
  switch (STATE) {
    case 0:
      burst();
      Serial.println("burst");
      break;
    case 1:
      stillIncandescent();
      Serial.println("STILL INCANDESCENT");
      break;
    case 2:
      incandescent();
      Serial.println("INCANDESCENT");
      break;
     case 3:
      lightningIdle();
      Serial.println("LIGHTNING");
      break;
  }
}

What is the code supposed to do and what does it actually do ?

Do not screenshot the warnings. If you want to post them then copy them by selecting with the mouse, then use Ctrl+A to copy them to the clipboard and post them here in code tags

The code is to cycle through several animations via a potentiometer. Here is a youtube link to give a better visualization

Edited. The warnings posted below with the code tags

Usually, the compiler has detected an out-of-bounds error.

As you'll have noticed, it's best to post error messages in code tags.

Here it is. Took me a minute to figure out what the code tags where. Thank you










C:\Users\Craig Romanovich\Desktop\inter\Interior\Brain\Brain.ino: In function 'explode(int, int)':
C:\Users\Craig Romanovich\Desktop\inter\Interior\Brain\Brain.ino:183:23: warning: iteration 30 invokes undefined behavior [-Waggressive-loop-optimizations]
     if(leds[strip][i].red == 200 && leds[strip][i].blue == 255) { // If the LED just flashed a moment ago
        ~~~~~~~~~~~~~~~^~~
C:\Users\Craig Romanovich\Desktop\inter\Interior\Brain\Brain.ino:172:22: note: within this loop
    for (int i = 0; i < sizeof(leds[strip]); i++) {
                    ~~^~~~~~~~~
In file included from C:\Users\Craig Romanovich\Documents\Arduino\libraries\FastLED\src/controller.h:9:0,
                 from C:\Users\Craig Romanovich\Documents\Arduino\libraries\FastLED\src/FastLED.h:49,
                 from C:\Users\Craig Romanovich\Desktop\inter\Interior\Brain\Brain.ino:1:
C:\Users\Craig Romanovich\Desktop\inter\Interior\Brain\Brain.ino: In function 'red(int)':
C:\Users\Craig Romanovich\Documents\Arduino\libraries\FastLED\src/pixeltypes.h:172:11: warning: iteration 30 invokes undefined behavior [-Waggressive-loop-optimizations]
         r = nr;
         ~~^~~~
C:\Users\Craig Romanovich\Desktop\inter\Interior\Brain\Brain.ino:374:21: note: within this loop
   for (int i = 0; i < sizeof(leds[strip]); i++) {
                   ~~^~~~~~~~~
C:\Users\Craig Romanovich\Desktop\inter\Interior\Brain\Brain.ino: In function 'red':
C:\Users\Craig Romanovich\Documents\Arduino\libraries\FastLED\src/pixeltypes.h:172:11: warning: iteration 30 invokes undefined behavior [-Waggressive-loop-optimizations]
         r = nr;
           ^
C:\Users\Craig Romanovich\Desktop\inter\Interior\Brain\Brain.ino:374:21: note: within this loop
   for (int i = 0; i < sizeof(leds[strip]); i++) {
                     ^
C:\Users\Craig Romanovich\Desktop\inter\Interior\Brain\Brain.ino: In function 'explode.constprop':
C:\Users\Craig Romanovich\Desktop\inter\Interior\Brain\Brain.ino:183:23: warning: iteration 30 invokes undefined behavior [-Waggressive-loop-optimizations]
     if(leds[strip][i].red == 200 && leds[strip][i].blue == 255) { // If the LED just flashed a moment ago
                       ^
C:\Users\Craig Romanovich\Desktop\inter\Interior\Brain\Brain.ino:172:22: note: within this loop
    for (int i = 0; i < sizeof(leds[strip]); i++) {
                      ^
Sketch uses 17996 bytes (58%) of program storage space. Maximum is 30720 bytes.
Global variables use 1450 bytes (70%) of dynamic memory, leaving 598 bytes for local variables. Maximum is 2048 bytes.

type or paste code here

I see that you did not use code tags as suggested

Although this is a warning rather than an error it may be causing problems due to its nature

This for loop

   for (int i = 0; i < sizeof(leds[strip]); i++) {

may cause the access to the leds array to read outside of the array due to its use of sizeof() with a 2 dimensional array which returns the number of bytes used by the array rather than the number of elements in the array

So in that case, replace [strip] with the amount of leds on strip?

for (int i = 0; i <sizeof(leds[18]); i++) {

Warnings are good. The default should be to show all warnings during compile.

I think your problem is that you are defining the array leds as a two-dimension array. Maybe you meant:
CRGB leds[MAX_STRIPS * MAX_LED_STRIP];

The code is using the 'sizeof' operator incorrectly. It is using "sizeof leds[strip]" as the number of CRGB elements in the strip but 'sizeof' returns the size in bytes, not elements. This will cause your code to go WAY off the end of arrays.

One fix is to divide by the element size:
sizeof leds[strip] / sizeof leds[strip][0]
I think a better option is to use the defined constant:
MAX_LED_STRIP

There are a number of places where a byte (the 'blue' part of a color) is checked for "<= 255" which is always true for byte values. Those conditions can be removed.

In a few places "int i" is used as a for-loop index where the upper limit is 'unsigned'. The comparison of the signed 'i' with the unsigned limit generates a warning. Array sizes and indexes should be declared as type "size_t" (usually resolves to 'unsigned int').

Below is a version of the original source with those warnings fixed.

#include <FastLED.h>
#include <stdio.h>
#include <stdlib.h>
#include <hsv2rgb.h>

#define PIN12 12
#define PIN11 11
#define PIN10 10
#define PIN9 9
#define PIN8 8
#define PIN7 7
#define PIN6 6
#define PIN5 5

const size_t MAX_STRIPS = 8;
const size_t MAX_LED_STRIP = 30;

#define LIGHTNING_PROB 450

#define COLOR_ORDER RGB
#define LED_TYPE WS2812B

int STATE = 0;
int lastStates[8] = {0, 0, 0, 0, 0, 0, 0, 0}; // 0: incandescent, 1: lightning, 2: burst
int time_stamp = 0;
int buttonKnob = 0;
int burstStage = 0;
int pace = 60;
int burstOption = 0;
int lastState = 0;
int ticksExplode = 0;
bool burstToIdle = false;


uint8_t max_brightness = 255;
CRGB leds[MAX_STRIPS][MAX_LED_STRIP];

void lightning(int strip, int maxlength, int probability);
void incandescentYellow(int strip, int maxlength);
void incandescentRed(int strip, int maxlength);
void incandescent();
void lightningIdle();
void burst();
void gatherForBurst(int strip);
void prepareForBurst(int strip);
void explode(int strip);
void off();
void turnOff(int strip);
void stillIncandescent();
void red(int strip);

void setup()
{
  // put your setup code here, to run once:
  Serial.begin(9600);
  delay(1000); // sleep for one second, to give you time to do a pose
  pinMode(buttonKnob, INPUT);

  LEDS.addLeds<LED_TYPE, PIN8, COLOR_ORDER>(leds[0], 12);// We are telling FastLed that we have a 15 LED strip of the type WS2812B connected to pin 12
  LEDS.addLeds<LED_TYPE, PIN5, COLOR_ORDER>(leds[1], 18);
  LEDS.addLeds<LED_TYPE, PIN11, COLOR_ORDER>(leds[2], 18);
  // Hammer head LEDs
  LEDS.addLeds<LED_TYPE, PIN10, COLOR_ORDER>(leds[3], 16); // Hammer head bottom
  LEDS.addLeds<LED_TYPE, PIN6, COLOR_ORDER>(leds[4], 16); // Hammer head top
  LEDS.addLeds<LED_TYPE, PIN12, COLOR_ORDER>(leds[5], 10); // Hammer head left
  LEDS.addLeds<LED_TYPE, PIN9, COLOR_ORDER>(leds[6], 10); // Hammer head right
  LEDS.addLeds<LED_TYPE, PIN7, COLOR_ORDER>(leds[7], 24); // Hammer head ring

  FastLED.setBrightness(max_brightness);
}

void burst()
{
  switch (burstStage)
  {
    case 0:
      gatherForBurst(0);
      lastStates[0] = 2;
      break;
    case 1:
      prepareForBurst(0);
      break;
    case 2:
      explode(0, 100);
      explode(1, 100);
      explode(2, 100);
      explode(3, 100);
      explode(4, 100);
      explode(5, 100);
      delay(1000 / 60);
      break;
    case 3:
      burstToIdle = true;
      STATE = 3;
      break;
  }

}

void gatherForBurst(int strip)
{
  //CRGB dimmedWhite(5,5,5);
  //fill_solid(leds[strip], MAX_LED_STRIP, dimmedWhite);
  for (int i = 14 - 1; i >= 0; i--)
  {
    CHSV color = rgb2hsv_approximate(leds[strip][i]);
    if (lastStates[strip] != 2)
    {
      leds[0][i].setRGB(97, 63, 169); // Turn all the LED strip to a soft blue
      leds[1][i].setRGB(97, 63, 169); // Turn all the LED strip to a soft blue
      leds[2][i].setRGB(97, 63, 169); // Turn all the LED strip to a soft blue
      Serial.println("Soft blue");
      FastLED.show();
      if (i >= 18 - 1)
      {
        pace = pace - 30;
      }
      if (i <= 5)
      {
        pace = pace + 30;
      }
    }
    else if (leds[strip][i].blue == 0 || i == MAX_LED_STRIP - 1) // if it's ready for a flash
    {
      leds[strip][i].setRGB(200, 200, 255); // Flash
      if (i - 1 > 0) // Prepare for flash
      {
        leds[0][i].setRGB(0, 0, 0);
        leds[1][i].setRGB(0, 0, 0);
        leds[2][i].setRGB(0, 0, 0);
        Serial.println("Preparing");
        FastLED.show();
      }
      if (i >= 18 - 1)
      {
        pace = pace - 30;
      }
      if (i <= 5)
      {
        pace = pace + 30;
      }
    }
    else
    {
      leds[0][i].setHSV(color.h, color.s, color.v - 15);
      leds[1][i].setHSV(color.h, color.s, color.v - 15);
      leds[2][i].setHSV(color.h, color.s, color.v - 15);
      leds[3][i].setHSV(color.h, color.s, color.v - 15);
      leds[4][i].setHSV(color.h, color.s, color.v - 15);
      leds[5][i].setHSV(color.h, color.s, color.v - 15);
      leds[6][i].setHSV(color.h, color.s, color.v - 15);
      leds[7][i].setHSV(color.h, color.s, color.v - 15);
      pace = 360;
      FastLED.show();
      Serial.println("Dimming");
      //Serial.println(color.v);
      if (color.v - 25 <= 50 && i == 1)
      {
        ticksExplode = 0;
        burstStage = 2;
        Serial.println(pace);
      }
    }

    if (i > 0)
      delay(1000 / pace);
  }
}

void prepareForBurst(int strip)
{
  Serial.println("Preparing for burst");
  for (size_t i = 0; i < MAX_LED_STRIP; i++)
  {
    CHSV color = rgb2hsv_approximate(leds[strip][i]);
    leds[strip][i].setHSV(208, 50, color.v - 5);
    Serial.println("Fading to dim white");
    if (color.v - 5 <= 15)
      burstStage = 2;
  }
}

void explode(int strip, int probability)
{
  Serial.println("EXPLODE");
  for (size_t i = 0; i < MAX_LED_STRIP; i++)
  {
    CHSV color = rgb2hsv_approximate(leds[strip][i]);
    int flash = rand() % probability; // 1 out of 50
    if (flash == 2)
    {
      // we get it ready for a flash. Principle of anticipation.
      //leds[strip][i].setRGB(44, 66, 127);
      CRGB flash = CRGB(200, 200, 255);
      fill_solid(leds[strip], MAX_LED_STRIP, flash);
      //Serial.println("GETREADY");
    }
    // We check the state of that LED
    if (leds[strip][i].red == 200 && leds[strip][i].blue == 255)  // If the LED just flashed a moment ago
    {
      leds[strip][i].setHSV(213, 100, 100); // We fade it to blue
    }
    else
    {
      //if(rand()%10 == 1)
      leds[strip][i].setHSV(213, 100, color.v - 1);
      //leds[strip][i].setRGB(leds[strip][i].red - 40, leds[strip][i].green - 40, leds[strip][i].blue--); // Keep fading down
      //Serial.println("KEEP FADING TO BLUE");
      if (color.v <= 80)
      {
        leds[strip][i].setHSV(213, 100, 80);
        if (rand() % 60 == 1)
        {
          if (color.v < 80 && color.v > 0)
          {
            if (rand() % 2 == 1)
            {
              leds[strip][i].setHSV(213, 100, color.v - 1);
            }
            else
            {
              leds[strip][i].setHSV(213, 100, color.v + 1);
            }
          }
        }
      }

    }
    lastStates[strip] = 2;
    ticksExplode++;
    if (ticksExplode >= 10000)
    {
      burstStage = 3;
    }
  }
  FastLED.show();
}

/*
   Function ligthningIdle. It calls lightning on all of the LED strips
   Params:
*/
void lightningIdle()
{
  // Reset the timestamp
  burstStage = 0;
  // Here we call the lightning on all our LED Strips
  lightning(0, 12, 200);
  lightning(1, 18, 200);
  lightning(2, 18, 200);

  lightning(3, 16, 200);
  lightning(4, 16, 200);
  lightning(5, 10, 200);
  lightning(6, 10, 200);
  lightning(7, 24, 200);

  /*

    lightning(&B, NUM_LEDS_B);
    lightning(&C NUM_LEDS_C);
    lightning(&D, NUM_LEDS_D);
    lightning(&E, NUM_LEDS_E);
    lightning(&F, NUM_LEDS_F);
    lightning(&G, NUM_LEDS_G);
    lightning(&H, NUM_LEDS_H);
  */

  delay(1000 / 30);
}

/*
   Function incandescent. It calls incandescentYellow and Red depending on the strip
   Params:
*/
void incandescent()
{
  burstStage = 0;
  incandescentRed(0, 12);
  incandescentYellow(1, 18);
  incandescentRed(2, 18);
  incandescentRed(3, 16);
  incandescentRed(4, 16);
  incandescentYellow(5, 10);
  incandescentYellow(6, 10);
  incandescentRed(7, 24);


  delay(1000 / 120);
}

/*
   Function ligthning. It calls the lightning animation on a single LED strip
   Params: strip. It's the number of the LED strip. Meaning, we can call this function with any of the strips we have and it will work. * means it's a pointer to the first LED of the strip
            maxlength. the size of the LED strip
*/

void lightning(int strip, int maxlength, int probability)
{
  // We loop through the LED strip
  /*
     BLUE: 80, 150, 220 - 130, 180, 230
     GET READY: 44, 66, 127
     FLASH: 255, 255, 255
  */
  //fill_solid(leds[strip], maxlength, CRGB::White);
  for (int i = 0; i < maxlength; i++)
  {
    // Prepare random for a flash
    if (leds[strip][i].blue == 0)
    {
      if (rand() % probability == 1)
        leds[strip][i].setRGB(0, 0, 0);
    }
    CHSV color = rgb2hsv_approximate(leds[strip][i]);
    int flash = rand() % probability; // 1 out of 50
    if (flash == 2)
    {
      // we get it ready for a flash. Principle of anticipation.
      //leds[strip][i].setRGB(44, 66, 127);
      leds[strip][i].setRGB(0, 0, 0);
      //Serial.println("GETREADY");
    }
    // We check the state of that LED
    if (leds[strip][i].red == 0 && leds[strip][i].blue == 0)   // If the LED is ready for a flash
    {
      leds[strip][i].setRGB(255, 255, 255); // We make it flash white

      if (i + 1 < maxlength)
        leds[strip][i + 1].setRGB(194, 132, 248);// And the next 2 LEDs too
      if (i - 1 < maxlength)
        leds[strip][i - 1].setRGB(194, 132, 248); // And the next 2 LEDs too
    }
    else if ((leds[strip][i].red == 255 && leds[strip][i].blue == 255) || leds[strip][i].blue == 248 || burstToIdle == true)     // If the LED just flashed a moment ago
    {
      //Serial.println("FADE TO BLUE");
      leds[strip][i].setHSV(190, 100, 100); // We fade it to blue
    }
    else
    {
      //if(rand()%10 == 1)
      leds[strip][i].setHSV(190, 100, color.v - 1);
      //leds[strip][i].setRGB(leds[strip][i].red - 40, leds[strip][i].green - 40, leds[strip][i].blue--); // Keep fading down
      //Serial.println("KEEP FADING TO BLUE");
      if (color.v <= 80)
      {
        leds[strip][i].setHSV(190, 100, 80);
        if (rand() % 60 == 1)
        {
          if (color.v < 80 && color.v > 0)
          {
            if (rand() % 2 == 1)
            {
              leds[strip][i].setHSV(190, 100, color.v - 1);
            }
            else
            {
              leds[strip][i].setHSV(190, 100, color.v + 1);
            }
          }
        }
      }
    }

    //FastLED.show();
    //delay(1000/120);
  }
  lastStates[strip] = 1;
  FastLED.show();
}

void incandescentYellow(int strip, int maxlength)
{
  /*
     Colours:
     - Bright Yellow: 255, 255, 0
     - Dark orange: 255, 50, 0
     - Bright orange: 255, 100, 0
  */
  //fill_solid(leds[strip], maxlength, CRGB::Red);
  // First, glow everything to bright yellow

  for (int i = 0; i < maxlength; i++)
  {
    if (leds[strip][i].blue > 0)
    {
      leds[strip][i].setRGB(1, 30, 0);
    }
    if (leds[strip][i].red == 0)
    {
      leds[strip][i].setRGB(1, 30, 0);
      //Serial.println("Init");
    }
    else if (leds[strip][i].red >= 1 && leds[strip][i].red < 255)
    {

      Serial.println(leds[strip][i].red);
      //Serial.println(color.hue);
      leds[strip][i].setRGB(leds[strip][i].red + 1, leds[strip][i].green + 1, 0); // We add up a little bit of red and green light (yellow)
    }
    if (leds[strip][i].red >= 30)
    {
      leds[strip][i].red = 30;
    }
  }

  lastStates[strip] = 0;
  FastLED.show();
}
void red(int strip)
{
  /*
     Colours:
     - Bright Yellow: 255, 255, 0
     - Dark orange: 255, 50, 0
     - Bright orange: 255, 100, 0
  */
  //fill_solid(leds[strip], maxlength, CRGB::Red);

  for (size_t i = 0; i < MAX_LED_STRIP; i++)
  {
    leds[strip][i].setRGB(1, 30, 0);
  }

  FastLED.show();
  lastStates[strip] = 0;
}
void incandescentRed(int strip, int maxlength)
{
  /*
     Colours:
     - Bright Yellow: 255, 255, 0
     - Dark orange: 255, 50, 0
     - Bright orange: 255, 100, 0
  */
  //fill_solid(leds[strip], maxlength, CRGB::Red);

  for (int i = 0; i < maxlength; i++)
  {
    if (leds[strip][i].blue > 1)
    {
      if (rand() % 2 == 0)
      {
        leds[strip][i].setRGB(1, 30, 0);
      }
      else
      {
        leds[strip][i].setRGB(1, 30, 1);
      }
    }
    if (leds[strip][i].red == 0)
    {
      if (rand() % 4 == 0)
      {
        leds[strip][i].setRGB(1, 30, 1);
      }
      else
      {
        leds[strip][i].setRGB(1, 30, 0);
      }
      //Serial.println("Init");
    }
    else if (leds[strip][i].red >= 1 && leds[strip][i].red < 255)
    {
      int red = leds[strip][i].red; Serial.println("blue");
      red = red + 1;
      if (leds[strip][i].blue == 1)
      {
        Serial.println("blue");
        leds[strip][i].setRGB(red, leds[strip][i].green + 1, 1); // We add up a little bit of red and green light (yellow)
      }
      else
      {
        //leds[strip][i].setRGB(red, leds[strip][i].green + 1, 0); // We add up a little bit of red and green light (yellow)
      }
      //
    }
    if (leds[strip][i].red >= 20)
    {
      leds[strip][i].red = 20;
    }
  }
  FastLED.show();
  lastStates[strip] = 0;
}

void stillIncandescent()
{
  red(0);
  incandescentYellow(1, 18);
  red(2);
  red(3);
  red(4);
  incandescentYellow(5, 10);
  incandescentYellow(6, 10);
  red(7);
  delay(1000 / 30);
}

void turnOff(int strip)
{
  fill_solid(leds[strip], MAX_LED_STRIP, CRGB::Black);
}

void off()
{
  for (size_t i = 0; i < MAX_STRIPS - 1; i++)
  {
    turnOff(i);
  }
}

void loop()
{
  // He we have our Finite State Machine (the brain of the Stormbreaker where we will send our animation request using the potentiometer (knob)
  // First we read the input from the knob, which is the voltage and we transform it to a state
  time_stamp++;
  lastState = STATE;

  int val = analogRead(1);
  if (val >= 0 && val <= 255)
  {
    STATE = 0;
  }
  else if (val > 255 && val <= 512)
  {
    STATE = 1;
  }
  else if (val > 512 && val <= 768)
  {
    STATE = 2;
  }
  else if (val > 768 && val <= 1024)
  {
    STATE = 3;
  }

  if (burstToIdle == true)
  {
    STATE = 3;
  }

  //lightningIdle();
  // Then we run our state machine

  switch (STATE)
  {
    case 0:
      burst();
      Serial.println("burst");
      break;
    case 1:
      stillIncandescent();
      Serial.println("STILL INCANDESCENT");
      break;
    case 2:
      incandescent();
      Serial.println("INCANDESCENT");
      break;
    case 3:
      lightningIdle();
      Serial.println("LIGHTNING");
      break;
  }
}

john

Thank you very much. Your corrections work perfect. As I go through both sets of codes, I am learning. Best part of theses hobbies, you have to learn. Thank you again.

Craig