FastLED and fadeToBlackBy

I am trying to incorporate this sketch into the second one. Both sketches work as expected, until I added the first to the second.

/// @file    RGBSetDemo.ino
/// @brief   Demonstrates how to create an LED group with CRGBArray
/// @example RGBSetDemo.ino

#include <FastLED.h>
#define NUM_LEDS 120

CRGBArray<NUM_LEDS> leds;


void setup() { 
  FastLED.addLeds<NEOPIXEL,3>(leds, NUM_LEDS); 
  randomSeed(analogRead(A0));
}
void loop(){
  int myVar=random(0,3);
  switch (myVar) {
  case 0:
  red();
  break;

  case 1:
  blue();
  break;

  case 2:
  white();
}
}
void red(){ 
  //static uint8_t hue;
  for(int i = 0; i < NUM_LEDS/2; i++) {   
    // fade everything out
    leds.fadeToBlackBy(random(10,25));
 


    // let's set an led value
    leds[i] = CRGB(250,0,0);

    // now, let's first 20 leds to the top 20 leds, 
    leds(NUM_LEDS/2,NUM_LEDS-1) = leds(NUM_LEDS/2 - 1 ,0);
    FastLED.delay(random (2,30));
  }  
}

void blue(){ 
  //static uint8_t hue;
  for(int i = 0; i < NUM_LEDS/2; i++) {   
    // fade everything out
    leds.fadeToBlackBy(random(10,25));

    // let's set an led value
    leds[i] = CRGB(0,0,250);

    // now, let's first 20 leds to the top 20 leds, 
    leds(NUM_LEDS/2,NUM_LEDS-1) = leds(NUM_LEDS/2 - 1 ,0);
    FastLED.delay(random(2,30));
  } 
}

void white(){ 
  //static uint8_t hue;
  for(int i = 0; i < NUM_LEDS/2; i++) {   
    // fade everything out
    leds.fadeToBlackBy(random(10,25));

    // let's set an led value
    leds[i] = CRGB(250,250,250);

    // now, let's first 20 leds to the top 20 leds, 
    leds(NUM_LEDS/2,NUM_LEDS-1) = leds(NUM_LEDS/2 - 1 ,0);
    FastLED.delay(random(2,30));
  } 
}
#include <FastLED.h>

#define NUM_LEDS  120
#define LED_PIN   3
CRGB leds[NUM_LEDS];
uint8_t data[ NUM_LEDS];


void setup() {
  delay(3000);
  FastLED.addLeds<WS2812B, LED_PIN, GRB>(leds, NUM_LEDS).setCorrection(TypicalLEDStrip);
  FastLED.setBrightness(100);
  FastLED.setMaxPowerInVoltsAndMilliamps(5, 1000);
  randomSeed(analogRead(A0));

}

void loop() {
  
  int seqVar = random(0, 9);

  //uint32_t period2 = .2 * 60000L;       // X minutes
    uint32_t period2 = random(10,20) * 1000L;       // X seconds
      for ( uint32_t tStart = millis();  (millis() - tStart) < period2; )
      
  switch (seqVar) {
      
    case 0:
      //uint32_t period2 = .1 * 60000L;       // X minutes
      //for ( uint32_t tStart = millis();  (millis() - tStart) < period2;  )
      movingDotred();
      break;

    case 1:
      //uint32_t period2 = .2 * 60000L;       // X minutes
      //for ( uint32_t tStart = millis();  (millis() - tStart) < period2;  )
      movingDotwhite();
      break;

    case 2:
      //uint32_t period2 = .2 * 60000L;       // X minutes
      //for ( uint32_t tStart = millis();  (millis() - tStart) < period2;  )
      movingDotblue();
      break;

    case 3:
      //uint32_t period3 = .3 * 60000L;       // X minutes
      //for ( uint32_t tStart = millis();  (millis() - tStart) < period2;  )
      phaseBeat();
      break;

    case 4:
      //uint32_t period3 = .3 * 60000L;       // X minutes
      //for ( uint32_t tStart = millis();  (millis() - tStart) < period2;  )
      redwhitebluestripeswithglitter();
      break;

    case 5:
      //uint32_t period3 = .3 * 60000L;       // X minutes
      //for ( uint32_t tStart = millis();  (millis() - tStart) < period2;  )
      RWBFadeInandOut();
      break;

    case 6:
      //uint32_t period3 = .3 * 60000L;       // X minutes
      //for ( uint32_t tStart = millis();  (millis() - tStart) < period2;  )
      NewKITT(0xff, 0, 0, 35, 2, 50);
      NewKITT(0, 0, 0xff, 35, 2, 50);
      NewKITT(0xff, 0xff, 0xff, 35, 2, 50);
      break;

    case 7:
      //uint32_t period3 = .3 * 60000L;       // X minutes
      //for ( uint32_t tStart = millis();  (millis() - tStart) < period2;  )
      theaterChase(0xff, 0, 0, 70);
      theaterChase(0xff, 0xff, 0xff, 70);
      theaterChase(0, 0, 0xff, 70);

    case 8:
      outsideinmeteors;

  }
}
void movingDotred() {
  uint16_t sinBeat = beatsin16(20, 0, NUM_LEDS - 1, 0, 0);

  leds[sinBeat] = CRGB::Red;
  fadeToBlackBy(leds, NUM_LEDS, 10);
  FastLED.show();
}

void movingDotwhite() {
  uint16_t sinBeat = beatsin16(20, 0, NUM_LEDS - 1, 0, 0);

  leds[sinBeat] = CRGB::White;
  fadeToBlackBy(leds, NUM_LEDS, 10);
  FastLED.show();
}
void movingDotblue() {
  uint16_t sinBeat = beatsin16(20, 0, NUM_LEDS - 1, 0, 0);

  leds[sinBeat] = CRGB::Blue;
  fadeToBlackBy(leds, NUM_LEDS, 10);
  FastLED.show();
}



void phaseBeat() {
  //  uint8_t sinBeat   = beatsin8(15, 0, NUM_LEDS - 1, 0, 0);
  //  uint8_t sinBeat2  = beatsin8(15, 0, NUM_LEDS - 1, 0, 85);
  //  uint8_t sinBeat3  = beatsin8(15, 0, NUM_LEDS - 1, 0, 170);

  // If you notice that your pattern is missing out certain LEDs, you
  // will need to use the higher resolution beatsin16 instead. In this
  // case remove the 3 lines above and replace them with the following:
  uint16_t sinBeat   = beatsin16(15, 0, NUM_LEDS - 1, 0, 0);
  uint16_t sinBeat2  = beatsin16(15, 0, NUM_LEDS - 1, 0, 21845);
  uint16_t sinBeat3  = beatsin16(15, 0, NUM_LEDS - 1, 0, 43690);

  leds[sinBeat]   = CRGB::Blue;
  leds[sinBeat2]  = CRGB::Red;
  leds[sinBeat3]  = CRGB::White;

  fadeToBlackBy(leds, NUM_LEDS, 10);
  FastLED.show();
}

void redwhitebluestripeswithglitter() {
  fill_data_array();
  render_data_with_palette();
  add_glitter();

  FastLED.show();
  FastLED.delay(20);
}

void fill_data_array()
{
  static uint8_t startValue = 0;
  startValue = startValue + 2;

  uint8_t value = startValue;
  for ( int i = 0; i < NUM_LEDS; i++) {
    data[i] = triwave8( value); // convert value to an up-and-down wave
    value += 3;
  }
}


CRGBPalette16 gPalette (
  CRGB::Black, CRGB::Black,
  CRGB::Red,   CRGB::Red,  CRGB::Red,  CRGB::Red,
  CRGB::Gray,  CRGB::Gray, CRGB::Gray, CRGB::Gray,
  CRGB::Blue,  CRGB::Blue, CRGB::Blue, CRGB::Blue,
  CRGB::Black, CRGB::Black
);

void render_data_with_palette()
{
  for ( int i = 0; i < NUM_LEDS; i++) {
    leds[i] = ColorFromPalette( gPalette, data[i], 128, LINEARBLEND);
  }
}

void add_glitter()
{
  int chance_of_glitter =  10; // percent of the time that we add glitter
  int number_of_glitters = 10; // number of glitter sparkles to add

  int r = random8(100);
  if ( r < chance_of_glitter ) {
    for ( int j = 0; j < number_of_glitters; j++) {
      int pos = random16( NUM_LEDS);
      leds[pos] = CRGB::White; // very bright glitter
    }
  }
}

void RWBFadeInandOut() {
  FadeInOut(0xff, 0x00, 0x00); // red
  FadeInOut(0xff, 0xff, 0xff); // white
  FadeInOut(0x00, 0x00, 0xff); // blue
}
void setAll(byte red, byte white, byte blue) {
  for (int i = 0; i < NUM_LEDS; i++ ) {
    setPixel(i, red, white, blue);
  }
  FastLED.show();
}

void setPixel(int Pixel, byte red, byte white, byte blue) {

  leds[Pixel].r = red;
  leds[Pixel].g = white;
  leds[Pixel].b = blue;

}
void FadeInOut(byte red, byte green, byte blue) {
  float r, g, b;

  for (int k = 0; k < 256; k = k + 5) {
    r = (k / 256.0) * red;
    g = (k / 256.0) * green;
    b = (k / 256.0) * blue;
    setAll(r, g, b);
    FastLED.show();
  }

  for (int k = 255; k >= 0; k = k - 5) {
    r = (k / 256.0) * red;
    g = (k / 256.0) * green;
    b = (k / 256.0) * blue;
    setAll(r, g, b);
    FastLED.show();
  }
}

void NewKITT(byte red, byte green, byte blue, int EyeSize, int SpeedDelay, int ReturnDelay) {
  RightToLeft(red, green, blue, EyeSize, SpeedDelay, ReturnDelay);
  LeftToRight(red, green, blue, EyeSize, SpeedDelay, ReturnDelay);
  OutsideToCenter(red, green, blue, EyeSize, SpeedDelay, ReturnDelay);
  CenterToOutside(red, green, blue, EyeSize, SpeedDelay, ReturnDelay);
  //  LeftToRight(red, green, blue, EyeSize, SpeedDelay, ReturnDelay);
  //  RightToLeft(red, green, blue, EyeSize, SpeedDelay, ReturnDelay);
  //  OutsideToCenter(red, green, blue, EyeSize, SpeedDelay, ReturnDelay);
  //  CenterToOutside(red, green, blue, EyeSize, SpeedDelay, ReturnDelay);
}

void CenterToOutside(byte red, byte green, byte blue, int EyeSize, int SpeedDelay, int ReturnDelay) {
  for (int i = ((NUM_LEDS - EyeSize) / 2); i >= 0; i--) {
    setAll(0, 0, 0);

    setPixel(i, red / 10, green / 10, blue / 10);
    for (int j = 1; j <= EyeSize; j++) {
      setPixel(i + j, red, green, blue);
    }
    setPixel(i + EyeSize + 1, red / 10, green / 10, blue / 10);

    setPixel(NUM_LEDS - i, red / 10, green / 10, blue / 10);
    for (int j = 1; j <= EyeSize; j++) {
      setPixel(NUM_LEDS - i - j, red, green, blue);
    }
    setPixel(NUM_LEDS - i - EyeSize - 1, red / 10, green / 10, blue / 10);

    FastLED.show();
    delay(SpeedDelay);
  }
  delay(ReturnDelay);
}

void OutsideToCenter(byte red, byte green, byte blue, int EyeSize, int SpeedDelay, int ReturnDelay) {
  for (int i = 0; i <= ((NUM_LEDS - EyeSize) / 2); i++) {
    setAll(0, 0, 0);

    setPixel(i, red / 10, green / 10, blue / 10);
    for (int j = 1; j <= EyeSize; j++) {
      setPixel(i + j, red, green, blue);
    }
    setPixel(i + EyeSize + 1, red / 10, green / 10, blue / 10);

    setPixel(NUM_LEDS - i, red / 10, green / 10, blue / 10);
    for (int j = 1; j <= EyeSize; j++) {
      setPixel(NUM_LEDS - i - j, red, green, blue);
    }
    setPixel(NUM_LEDS - i - EyeSize - 1, red / 10, green / 10, blue / 10);

    FastLED.show();
    delay(SpeedDelay);
  }
  delay(ReturnDelay);
}

void LeftToRight(byte red, byte green, byte blue, int EyeSize, int SpeedDelay, int ReturnDelay) {
  for (int i = 0; i < NUM_LEDS - EyeSize - 2; i++) {
    setAll(0, 0, 0);
    setPixel(i, red / 10, green / 10, blue / 10);
    for (int j = 1; j <= EyeSize; j++) {
      setPixel(i + j, red, green, blue);
    }
    setPixel(i + EyeSize + 1, red / 10, green / 10, blue / 10);
    FastLED.show();
    delay(SpeedDelay);
  }
  delay(ReturnDelay);
}

void RightToLeft(byte red, byte green, byte blue, int EyeSize, int SpeedDelay, int ReturnDelay) {
  for (int i = NUM_LEDS - EyeSize - 2; i > 0; i--) {
    setAll(0, 0, 0);
    setPixel(i, red / 10, green / 10, blue / 10);
    for (int j = 1; j <= EyeSize; j++) {
      setPixel(i + j, red, green, blue);
    }
    setPixel(i + EyeSize + 1, red / 10, green / 10, blue / 10);
    FastLED.show();
    delay(SpeedDelay);
  }
  delay(ReturnDelay);
}

void theaterChase(byte red, byte green, byte blue, int SpeedDelay) {
  for (int j = 0; j < 10; j++) { //do 10 cycles of chasing
    for (int q = 0; q < 3; q++) {
      for (int i = 0; i < NUM_LEDS; i = i + 3) {
        setPixel(i + q, red, green, blue);  //turn every third pixel on
      }
      FastLED.show();

      delay(SpeedDelay);

      for (int i = 0; i < NUM_LEDS; i = i + 3) {
        setPixel(i + q, 0, 0, 0);    //turn every third pixel off
      }
    }
  }
}

void outsideinmeteors(){
  int myVar=random(0,3);
  switch (myVar) {
  case 0:
  red();
  break;

  case 1:
  blue();
  break;

  case 2:
  white();
}
}
void red(){ 
  //static uint8_t hue;
  for(int i = 0; i < NUM_LEDS/2; i++) {   
    // fade everything out
    leds.fadeToBlackBy(random(10,25));

    // let's set an led value
    leds[i] = CRGB(250,0,0);

    // now, let's first 20 leds to the top 20 leds, 
    leds(NUM_LEDS/2,NUM_LEDS-1) = leds(NUM_LEDS/2 - 1 ,0);
    FastLED.delay(random (2,30));
  }  
}

void blue(){ 
  //static uint8_t hue;
  for(int i = 0; i < NUM_LEDS/2; i++) {   
    // fade everything out
    leds.fadeToBlackBy(random(10,25));

    // let's set an led value
    leds[i] = CRGB(0,0,250);

    // now, let's first 20 leds to the top 20 leds, 
    leds(NUM_LEDS/2,NUM_LEDS-1) = leds(NUM_LEDS/2 - 1 ,0);
    FastLED.delay(random(2,30));
  } 
}

void white(){ 
  //static uint8_t hue;
  for(int i = 0; i < NUM_LEDS/2; i++) {   
    // fade everything out
    leds.fadeToBlackBy(random(10,25));

    // let's set an led value
    leds[i] = CRGB(250,250,250);

    // now, let's first 20 leds to the top 20 leds, 
    leds(NUM_LEDS/2,NUM_LEDS-1) = leds(NUM_LEDS/2 - 1 ,0);
    FastLED.delay(random(2,30));
  } 
}

I am getting errors relating to my two ways of calling fadeToBlackBy. I think it relates to how I am defining my array - I am stretching my knowledge here.
I have tried changing the first sketch to more closely match the second - just in terms of CRGBArray definition but i am falling down a rabbit hole. I have watched few fadeToBlack vids but they shed no light.
Can someone suggest a way to go? Should I try to change the first sketch to be compatible with the second - how, or modify the second sketch?
Thanks -

Show us your combined version of this codes.

It is the second sketch, with the addition of a "break;" at the end of case 7.
Case 8 is what I am adding. It is the first sketch shown.

Code please.

#include <FastLED.h>

#define NUM_LEDS  120
#define LED_PIN   3
CRGB leds[NUM_LEDS];
uint8_t data[ NUM_LEDS];


void setup() {
  delay(3000);
  FastLED.addLeds<WS2812B, LED_PIN, GRB>(leds, NUM_LEDS).setCorrection(TypicalLEDStrip);
  FastLED.setBrightness(100);
  FastLED.setMaxPowerInVoltsAndMilliamps(5, 1000);
  randomSeed(analogRead(A0));

}

void loop() {
  
  int seqVar = random(0, 9);

  //uint32_t period2 = .2 * 60000L;       // X minutes
    uint32_t period2 = random(10,20) * 1000L;       // X seconds
      for ( uint32_t tStart = millis();  (millis() - tStart) < period2; )
      
  switch (seqVar) {
      
    case 0:
      //uint32_t period2 = .1 * 60000L;       // X minutes
      //for ( uint32_t tStart = millis();  (millis() - tStart) < period2;  )
      movingDotred();
      break;

    case 1:
      //uint32_t period2 = .2 * 60000L;       // X minutes
      //for ( uint32_t tStart = millis();  (millis() - tStart) < period2;  )
      movingDotwhite();
      break;

    case 2:
      //uint32_t period2 = .2 * 60000L;       // X minutes
      //for ( uint32_t tStart = millis();  (millis() - tStart) < period2;  )
      movingDotblue();
      break;

    case 3:
      //uint32_t period3 = .3 * 60000L;       // X minutes
      //for ( uint32_t tStart = millis();  (millis() - tStart) < period2;  )
      phaseBeat();
      break;

    case 4:
      //uint32_t period3 = .3 * 60000L;       // X minutes
      //for ( uint32_t tStart = millis();  (millis() - tStart) < period2;  )
      redwhitebluestripeswithglitter();
      break;

    case 5:
      //uint32_t period3 = .3 * 60000L;       // X minutes
      //for ( uint32_t tStart = millis();  (millis() - tStart) < period2;  )
      RWBFadeInandOut();
      break;

    case 6:
      //uint32_t period3 = .3 * 60000L;       // X minutes
      //for ( uint32_t tStart = millis();  (millis() - tStart) < period2;  )
      NewKITT(0xff, 0, 0, 35, 2, 50);
      NewKITT(0, 0, 0xff, 35, 2, 50);
      NewKITT(0xff, 0xff, 0xff, 35, 2, 50);
      break;

    case 7:
      //uint32_t period3 = .3 * 60000L;       // X minutes
      //for ( uint32_t tStart = millis();  (millis() - tStart) < period2;  )
      theaterChase(0xff, 0, 0, 70);
      theaterChase(0xff, 0xff, 0xff, 70);
      theaterChase(0, 0, 0xff, 70);
      break;

    case 8:
      outsideinmeteors;

  }
}
void movingDotred() {
  uint16_t sinBeat = beatsin16(20, 0, NUM_LEDS - 1, 0, 0);

  leds[sinBeat] = CRGB::Red;
  fadeToBlackBy(leds, NUM_LEDS, 10);
  FastLED.show();
}

void movingDotwhite() {
  uint16_t sinBeat = beatsin16(20, 0, NUM_LEDS - 1, 0, 0);

  leds[sinBeat] = CRGB::White;
  fadeToBlackBy(leds, NUM_LEDS, 10);
  FastLED.show();
}
void movingDotblue() {
  uint16_t sinBeat = beatsin16(20, 0, NUM_LEDS - 1, 0, 0);

  leds[sinBeat] = CRGB::Blue;
  fadeToBlackBy(leds, NUM_LEDS, 10);
  FastLED.show();
}



void phaseBeat() {
  //  uint8_t sinBeat   = beatsin8(15, 0, NUM_LEDS - 1, 0, 0);
  //  uint8_t sinBeat2  = beatsin8(15, 0, NUM_LEDS - 1, 0, 85);
  //  uint8_t sinBeat3  = beatsin8(15, 0, NUM_LEDS - 1, 0, 170);

  // If you notice that your pattern is missing out certain LEDs, you
  // will need to use the higher resolution beatsin16 instead. In this
  // case remove the 3 lines above and replace them with the following:
  uint16_t sinBeat   = beatsin16(15, 0, NUM_LEDS - 1, 0, 0);
  uint16_t sinBeat2  = beatsin16(15, 0, NUM_LEDS - 1, 0, 21845);
  uint16_t sinBeat3  = beatsin16(15, 0, NUM_LEDS - 1, 0, 43690);

  leds[sinBeat]   = CRGB::Blue;
  leds[sinBeat2]  = CRGB::Red;
  leds[sinBeat3]  = CRGB::White;

  fadeToBlackBy(leds, NUM_LEDS, 10);
  FastLED.show();
}

void redwhitebluestripeswithglitter() {
  fill_data_array();
  render_data_with_palette();
  add_glitter();

  FastLED.show();
  FastLED.delay(20);
}

void fill_data_array()
{
  static uint8_t startValue = 0;
  startValue = startValue + 2;

  uint8_t value = startValue;
  for ( int i = 0; i < NUM_LEDS; i++) {
    data[i] = triwave8( value); // convert value to an up-and-down wave
    value += 3;
  }
}


CRGBPalette16 gPalette (
  CRGB::Black, CRGB::Black,
  CRGB::Red,   CRGB::Red,  CRGB::Red,  CRGB::Red,
  CRGB::Gray,  CRGB::Gray, CRGB::Gray, CRGB::Gray,
  CRGB::Blue,  CRGB::Blue, CRGB::Blue, CRGB::Blue,
  CRGB::Black, CRGB::Black
);

void render_data_with_palette()
{
  for ( int i = 0; i < NUM_LEDS; i++) {
    leds[i] = ColorFromPalette( gPalette, data[i], 128, LINEARBLEND);
  }
}

void add_glitter()
{
  int chance_of_glitter =  10; // percent of the time that we add glitter
  int number_of_glitters = 10; // number of glitter sparkles to add

  int r = random8(100);
  if ( r < chance_of_glitter ) {
    for ( int j = 0; j < number_of_glitters; j++) {
      int pos = random16( NUM_LEDS);
      leds[pos] = CRGB::White; // very bright glitter
    }
  }
}

void RWBFadeInandOut() {
  FadeInOut(0xff, 0x00, 0x00); // red
  FadeInOut(0xff, 0xff, 0xff); // white
  FadeInOut(0x00, 0x00, 0xff); // blue
}
void setAll(byte red, byte white, byte blue) {
  for (int i = 0; i < NUM_LEDS; i++ ) {
    setPixel(i, red, white, blue);
  }
  FastLED.show();
}

void setPixel(int Pixel, byte red, byte white, byte blue) {

  leds[Pixel].r = red;
  leds[Pixel].g = white;
  leds[Pixel].b = blue;

}
void FadeInOut(byte red, byte green, byte blue) {
  float r, g, b;

  for (int k = 0; k < 256; k = k + 5) {
    r = (k / 256.0) * red;
    g = (k / 256.0) * green;
    b = (k / 256.0) * blue;
    setAll(r, g, b);
    FastLED.show();
  }

  for (int k = 255; k >= 0; k = k - 5) {
    r = (k / 256.0) * red;
    g = (k / 256.0) * green;
    b = (k / 256.0) * blue;
    setAll(r, g, b);
    FastLED.show();
  }
}

void NewKITT(byte red, byte green, byte blue, int EyeSize, int SpeedDelay, int ReturnDelay) {
  RightToLeft(red, green, blue, EyeSize, SpeedDelay, ReturnDelay);
  LeftToRight(red, green, blue, EyeSize, SpeedDelay, ReturnDelay);
  OutsideToCenter(red, green, blue, EyeSize, SpeedDelay, ReturnDelay);
  CenterToOutside(red, green, blue, EyeSize, SpeedDelay, ReturnDelay);
  //  LeftToRight(red, green, blue, EyeSize, SpeedDelay, ReturnDelay);
  //  RightToLeft(red, green, blue, EyeSize, SpeedDelay, ReturnDelay);
  //  OutsideToCenter(red, green, blue, EyeSize, SpeedDelay, ReturnDelay);
  //  CenterToOutside(red, green, blue, EyeSize, SpeedDelay, ReturnDelay);
}

void CenterToOutside(byte red, byte green, byte blue, int EyeSize, int SpeedDelay, int ReturnDelay) {
  for (int i = ((NUM_LEDS - EyeSize) / 2); i >= 0; i--) {
    setAll(0, 0, 0);

    setPixel(i, red / 10, green / 10, blue / 10);
    for (int j = 1; j <= EyeSize; j++) {
      setPixel(i + j, red, green, blue);
    }
    setPixel(i + EyeSize + 1, red / 10, green / 10, blue / 10);

    setPixel(NUM_LEDS - i, red / 10, green / 10, blue / 10);
    for (int j = 1; j <= EyeSize; j++) {
      setPixel(NUM_LEDS - i - j, red, green, blue);
    }
    setPixel(NUM_LEDS - i - EyeSize - 1, red / 10, green / 10, blue / 10);

    FastLED.show();
    delay(SpeedDelay);
  }
  delay(ReturnDelay);
}

void OutsideToCenter(byte red, byte green, byte blue, int EyeSize, int SpeedDelay, int ReturnDelay) {
  for (int i = 0; i <= ((NUM_LEDS - EyeSize) / 2); i++) {
    setAll(0, 0, 0);

    setPixel(i, red / 10, green / 10, blue / 10);
    for (int j = 1; j <= EyeSize; j++) {
      setPixel(i + j, red, green, blue);
    }
    setPixel(i + EyeSize + 1, red / 10, green / 10, blue / 10);

    setPixel(NUM_LEDS - i, red / 10, green / 10, blue / 10);
    for (int j = 1; j <= EyeSize; j++) {
      setPixel(NUM_LEDS - i - j, red, green, blue);
    }
    setPixel(NUM_LEDS - i - EyeSize - 1, red / 10, green / 10, blue / 10);

    FastLED.show();
    delay(SpeedDelay);
  }
  delay(ReturnDelay);
}

void LeftToRight(byte red, byte green, byte blue, int EyeSize, int SpeedDelay, int ReturnDelay) {
  for (int i = 0; i < NUM_LEDS - EyeSize - 2; i++) {
    setAll(0, 0, 0);
    setPixel(i, red / 10, green / 10, blue / 10);
    for (int j = 1; j <= EyeSize; j++) {
      setPixel(i + j, red, green, blue);
    }
    setPixel(i + EyeSize + 1, red / 10, green / 10, blue / 10);
    FastLED.show();
    delay(SpeedDelay);
  }
  delay(ReturnDelay);
}

void RightToLeft(byte red, byte green, byte blue, int EyeSize, int SpeedDelay, int ReturnDelay) {
  for (int i = NUM_LEDS - EyeSize - 2; i > 0; i--) {
    setAll(0, 0, 0);
    setPixel(i, red / 10, green / 10, blue / 10);
    for (int j = 1; j <= EyeSize; j++) {
      setPixel(i + j, red, green, blue);
    }
    setPixel(i + EyeSize + 1, red / 10, green / 10, blue / 10);
    FastLED.show();
    delay(SpeedDelay);
  }
  delay(ReturnDelay);
}

void theaterChase(byte red, byte green, byte blue, int SpeedDelay) {
  for (int j = 0; j < 10; j++) { //do 10 cycles of chasing
    for (int q = 0; q < 3; q++) {
      for (int i = 0; i < NUM_LEDS; i = i + 3) {
        setPixel(i + q, red, green, blue);  //turn every third pixel on
      }
      FastLED.show();

      delay(SpeedDelay);

      for (int i = 0; i < NUM_LEDS; i = i + 3) {
        setPixel(i + q, 0, 0, 0);    //turn every third pixel off
      }
    }
  }
}

void outsideinmeteors(){
  int myVar=random(0,3);
  switch (myVar) {
  case 0:
  red();
  break;

  case 1:
  blue();
  break;

  case 2:
  white();
}
}
void red(){ 
  //static uint8_t hue;
  for(int i = 0; i < NUM_LEDS/2; i++) {   
    // fade everything out
    leds.fadeToBlackBy(random(10,25));
    
    // let's set an led value
    leds[i] = CRGB(250,0,0);

    // now, let's first 20 leds to the top 20 leds, 
    leds(NUM_LEDS/2,NUM_LEDS-1) = leds(NUM_LEDS/2 - 1 ,0);
    FastLED.delay(random (2,30));
  }  
}

void blue(){ 
  //static uint8_t hue;
  for(int i = 0; i < NUM_LEDS/2; i++) {   
    // fade everything out
    leds.fadeToBlackBy(random(10,25));

    // let's set an led value
    leds[i] = CRGB(0,0,250);

    // now, let's first 20 leds to the top 20 leds, 
    leds(NUM_LEDS/2,NUM_LEDS-1) = leds(NUM_LEDS/2 - 1 ,0);
    FastLED.delay(random(2,30));
  } 
}

void white(){ 
  //static uint8_t hue;
  for(int i = 0; i < NUM_LEDS/2; i++) {   
    // fade everything out
    leds.fadeToBlackBy(random(10,25));

    // let's set an led value
    leds[i] = CRGB(250,250,250);

    // now, let's first 20 leds to the top 20 leds, 
    leds(NUM_LEDS/2,NUM_LEDS-1) = leds(NUM_LEDS/2 - 1 ,0);
    FastLED.delay(random(2,30));
  } 
}

There's a ton of functions being called and you didn't functions prototype on top of your code for this reason you are getting errors like "function X was not declared on scope".

Before the setup try add all functions prototypes like this:

void fill_data_array();

void render_data_with_palette();

void add_glitter();

void FadeInOut(byte red, byte green, byte blue);

void setPixel(int Pixel, byte red, byte white, byte blue);

void RightToLeft(byte red, byte green, byte blue, int EyeSize, int SpeedDelay, int ReturnDelay);

void LeftToRight(byte red, byte green, byte blue, int EyeSize, int SpeedDelay, int ReturnDelay);

void OutsideToCenter(byte red, byte green, byte blue, int EyeSize, int SpeedDelay, int ReturnDelay);

void CenterToOutside(byte red, byte green, byte blue, int EyeSize, int SpeedDelay, int ReturnDelay);

void red();

void blue();

void white();

After the fix above I can see this errors:

src/main.cpp:315:38: error: too few arguments to function 'void fadeToBlackBy(CRGB*, uint16_t, uint8_t)'
     fadeToBlackBy(leds, random(10,25));
                                      ^
In file included from .pio/libdeps/mega2560/FastLED/src/FastLED.h:60:0,
                 from src/main.cpp:1:
.pio/libdeps/mega2560/FastLED/src/colorutils.h:248:6: note: declared here
 void fadeToBlackBy( CRGB* leds, uint16_t num_leds, uint8_t fadeBy);
      ^~~~~~~~~~~~~
src/main.cpp:321:35: error: 'leds' cannot be used as a function
     leds(NUM_LEDS / 2,NUM_LEDS - 1) = leds(NUM_LEDS / 2 - 1,0);
                                   ^
src/main.cpp:321:62: error: 'leds' cannot be used as a function
     leds(NUM_LEDS / 2,NUM_LEDS - 1) = leds(NUM_LEDS / 2 - 1,0);
                                                              ^
src/main.cpp: In function 'void blue()':
src/main.cpp:332:10: error: request for member 'fadeToBlackBy' in 'leds', which is of non-class type 'CRGB [120]'
     leds.fadeToBlackBy(random(10,25));
          ^~~~~~~~~~~~~
src/main.cpp:338:35: error: 'leds' cannot be used as a function
     leds(NUM_LEDS / 2,NUM_LEDS - 1) = leds(NUM_LEDS / 2 - 1,0);
                                   ^
src/main.cpp:338:62: error: 'leds' cannot be used as a function
     leds(NUM_LEDS / 2,NUM_LEDS - 1) = leds(NUM_LEDS / 2 - 1,0);
                                                              ^
src/main.cpp: In function 'void white()':
src/main.cpp:349:10: error: request for member 'fadeToBlackBy' in 'leds', which is of non-class type 'CRGB [120]'
     leds.fadeToBlackBy(random(10,25));
          ^~~~~~~~~~~~~
src/main.cpp:355:35: error: 'leds' cannot be used as a function
     leds(NUM_LEDS / 2,NUM_LEDS - 1) = leds(NUM_LEDS / 2 - 1,0);
                                   ^
src/main.cpp:355:62: error: 'leds' cannot be used as a function
     leds(NUM_LEDS / 2,NUM_LEDS - 1) = leds(NUM_LEDS / 2 - 1,0);

Looks like you are using functions in wrong way.

leds.fadeToBlackBy(random(10,25));

From what I can see here the line below should be:

fadeToBlackBy(leds, random(10,25), some number);

I don't know this library very well so someone else could help you.

Yes, I've cleaned up the fadeToBlackBy commands, 3x.
I am now just getting the error message that deals with

Unless someone can help I may just have to keep pulling my hair out, or learn how to control leds!

What puzzles me is that the very first sketch I posted has that leds command, 3x, and it works great. As I have said, it must be how I am defining the array in the first sketch vs the second sketch.

Edit:

The problem is here:

CRGB leds[NUM_LEDS];

Change to:

CRGBArray <NUM_LEDS> leds;

Boy, that was simple. Thanks. Now everything compiles - but, now when outsideinsidemeteors is called the strips freeze until the time is up, then resumes with the random function selection. In my pasted sketch I am only selecting sketch 7 or 8.
I wonder if it has something to do with a switch/case within a switch/case, or a random() within a random()?
PS - I have done nothing with your suggestion to clean up my functions prototype - not yet.

#include <FastLED.h>

#define NUM_LEDS  180
#define LED_PIN   3
//CRGB leds[NUM_LEDS];
CRGBArray <NUM_LEDS> leds;
uint8_t data[ NUM_LEDS];


void setup() {
  delay(3000);
  FastLED.addLeds<WS2812B, LED_PIN, GRB>(leds, NUM_LEDS).setCorrection(TypicalLEDStrip);
  FastLED.setBrightness(100);
  FastLED.setMaxPowerInVoltsAndMilliamps(5, 1000);
  randomSeed(analogRead(A0));

}

void loop() {
  
  int seqVar = random(7, 9);

  //uint32_t period2 = .2 * 60000L;       // X minutes
    uint32_t period2 = random(10,20) * 1000L;       // X seconds
      for ( uint32_t tStart = millis();  (millis() - tStart) < period2; )
      
  switch (seqVar) {
      
    case 0:
      //uint32_t period2 = .1 * 60000L;       // X minutes
      //for ( uint32_t tStart = millis();  (millis() - tStart) < period2;  )
      movingDotred();
      break;

    case 1:
      //uint32_t period2 = .2 * 60000L;       // X minutes
      //for ( uint32_t tStart = millis();  (millis() - tStart) < period2;  )
      movingDotwhite();
      break;

    case 2:
      //uint32_t period2 = .2 * 60000L;       // X minutes
      //for ( uint32_t tStart = millis();  (millis() - tStart) < period2;  )
      movingDotblue();
      break;

    case 3:
      //uint32_t period3 = .3 * 60000L;       // X minutes
      //for ( uint32_t tStart = millis();  (millis() - tStart) < period2;  )
      phaseBeat();
      break;

    case 4:
      //uint32_t period3 = .3 * 60000L;       // X minutes
      //for ( uint32_t tStart = millis();  (millis() - tStart) < period2;  )
      redwhitebluestripeswithglitter();
      break;

    case 5:
      //uint32_t period3 = .3 * 60000L;       // X minutes
      //for ( uint32_t tStart = millis();  (millis() - tStart) < period2;  )
      RWBFadeInandOut();
      break;

    case 6:
      //uint32_t period3 = .3 * 60000L;       // X minutes
      //for ( uint32_t tStart = millis();  (millis() - tStart) < period2;  )
      NewKITT(0xff, 0, 0, 35, 2, 50);
      NewKITT(0, 0, 0xff, 35, 2, 50);
      NewKITT(0xff, 0xff, 0xff, 35, 2, 50);
      break;

    case 7:
      //uint32_t period3 = .3 * 60000L;       // X minutes
      //for ( uint32_t tStart = millis();  (millis() - tStart) < period2;  )
      theaterChase(0xff, 0, 0, 70);
      theaterChase(0xff, 0xff, 0xff, 70);
      theaterChase(0, 0, 0xff, 70); 
      break;

     case 9:
     outsideinmeteors;  
  }
}
void movingDotred() {
  uint16_t sinBeat = beatsin16(20, 0, NUM_LEDS - 1, 0, 0);

  leds[sinBeat] = CRGB::Red;
  fadeToBlackBy(leds, NUM_LEDS, 10);
  FastLED.show();
}

void movingDotwhite() {
  uint16_t sinBeat = beatsin16(20, 0, NUM_LEDS - 1, 0, 0);

  leds[sinBeat] = CRGB::White;
  fadeToBlackBy(leds, NUM_LEDS, 10);
  FastLED.show();
}
void movingDotblue() {
  uint16_t sinBeat = beatsin16(20, 0, NUM_LEDS - 1, 0, 0);

  leds[sinBeat] = CRGB::Blue;
  fadeToBlackBy(leds, NUM_LEDS, 10);
  FastLED.show();
}



void phaseBeat() {
  //  uint8_t sinBeat   = beatsin8(15, 0, NUM_LEDS - 1, 0, 0);
  //  uint8_t sinBeat2  = beatsin8(15, 0, NUM_LEDS - 1, 0, 85);
  //  uint8_t sinBeat3  = beatsin8(15, 0, NUM_LEDS - 1, 0, 170);

  // If you notice that your pattern is missing out certain LEDs, you
  // will need to use the higher resolution beatsin16 instead. In this
  // case remove the 3 lines above and replace them with the following:
  uint16_t sinBeat   = beatsin16(15, 0, NUM_LEDS - 1, 0, 0);
  uint16_t sinBeat2  = beatsin16(15, 0, NUM_LEDS - 1, 0, 21845);
  uint16_t sinBeat3  = beatsin16(15, 0, NUM_LEDS - 1, 0, 43690);

  leds[sinBeat]   = CRGB::Blue;
  leds[sinBeat2]  = CRGB::Red;
  leds[sinBeat3]  = CRGB::White;

  fadeToBlackBy(leds, NUM_LEDS, 10);
  FastLED.show();
}

void redwhitebluestripeswithglitter() {
  fill_data_array();
  render_data_with_palette();
  add_glitter();

  FastLED.show();
  FastLED.delay(20);
}

void fill_data_array()
{
  static uint8_t startValue = 0;
  startValue = startValue + 2;

  uint8_t value = startValue;
  for ( int i = 0; i < NUM_LEDS; i++) {
    data[i] = triwave8( value); // convert value to an up-and-down wave
    value += 3;
  }
}


CRGBPalette16 gPalette (
  CRGB::Black, CRGB::Black,
  CRGB::Red,   CRGB::Red,  CRGB::Red,  CRGB::Red,
  CRGB::Gray,  CRGB::Gray, CRGB::Gray, CRGB::Gray,
  CRGB::Blue,  CRGB::Blue, CRGB::Blue, CRGB::Blue,
  CRGB::Black, CRGB::Black
);

void render_data_with_palette()
{
  for ( int i = 0; i < NUM_LEDS; i++) {
    leds[i] = ColorFromPalette( gPalette, data[i], 128, LINEARBLEND);
  }
}

void add_glitter()
{
  int chance_of_glitter =  10; // percent of the time that we add glitter
  int number_of_glitters = 10; // number of glitter sparkles to add

  int r = random8(100);
  if ( r < chance_of_glitter ) {
    for ( int j = 0; j < number_of_glitters; j++) {
      int pos = random16( NUM_LEDS);
      leds[pos] = CRGB::White; // very bright glitter
    }
  }
}

void RWBFadeInandOut() {
  FadeInOut(0xff, 0x00, 0x00); // red
  FadeInOut(0xff, 0xff, 0xff); // white
  FadeInOut(0x00, 0x00, 0xff); // blue
}
void setAll(byte red, byte white, byte blue) {
  for (int i = 0; i < NUM_LEDS; i++ ) {
    setPixel(i, red, white, blue);
  }
  FastLED.show();
}

void setPixel(int Pixel, byte red, byte white, byte blue) {

  leds[Pixel].r = red;
  leds[Pixel].g = white;
  leds[Pixel].b = blue;

}
void FadeInOut(byte red, byte green, byte blue) {
  float r, g, b;

  for (int k = 0; k < 256; k = k + 5) {
    r = (k / 256.0) * red;
    g = (k / 256.0) * green;
    b = (k / 256.0) * blue;
    setAll(r, g, b);
    FastLED.show();
  }

  for (int k = 255; k >= 0; k = k - 5) {
    r = (k / 256.0) * red;
    g = (k / 256.0) * green;
    b = (k / 256.0) * blue;
    setAll(r, g, b);
    FastLED.show();
  }
}

void NewKITT(byte red, byte green, byte blue, int EyeSize, int SpeedDelay, int ReturnDelay) {
  RightToLeft(red, green, blue, EyeSize, SpeedDelay, ReturnDelay);
  LeftToRight(red, green, blue, EyeSize, SpeedDelay, ReturnDelay);
  OutsideToCenter(red, green, blue, EyeSize, SpeedDelay, ReturnDelay);
  CenterToOutside(red, green, blue, EyeSize, SpeedDelay, ReturnDelay);
  //  LeftToRight(red, green, blue, EyeSize, SpeedDelay, ReturnDelay);
  //  RightToLeft(red, green, blue, EyeSize, SpeedDelay, ReturnDelay);
  //  OutsideToCenter(red, green, blue, EyeSize, SpeedDelay, ReturnDelay);
  //  CenterToOutside(red, green, blue, EyeSize, SpeedDelay, ReturnDelay);
}

void CenterToOutside(byte red, byte green, byte blue, int EyeSize, int SpeedDelay, int ReturnDelay) {
  for (int i = ((NUM_LEDS - EyeSize) / 2); i >= 0; i--) {
    setAll(0, 0, 0);

    setPixel(i, red / 10, green / 10, blue / 10);
    for (int j = 1; j <= EyeSize; j++) {
      setPixel(i + j, red, green, blue);
    }
    setPixel(i + EyeSize + 1, red / 10, green / 10, blue / 10);

    setPixel(NUM_LEDS - i, red / 10, green / 10, blue / 10);
    for (int j = 1; j <= EyeSize; j++) {
      setPixel(NUM_LEDS - i - j, red, green, blue);
    }
    setPixel(NUM_LEDS - i - EyeSize - 1, red / 10, green / 10, blue / 10);

    FastLED.show();
    delay(SpeedDelay);
  }
  delay(ReturnDelay);
}

void OutsideToCenter(byte red, byte green, byte blue, int EyeSize, int SpeedDelay, int ReturnDelay) {
  for (int i = 0; i <= ((NUM_LEDS - EyeSize) / 2); i++) {
    setAll(0, 0, 0);

    setPixel(i, red / 10, green / 10, blue / 10);
    for (int j = 1; j <= EyeSize; j++) {
      setPixel(i + j, red, green, blue);
    }
    setPixel(i + EyeSize + 1, red / 10, green / 10, blue / 10);

    setPixel(NUM_LEDS - i, red / 10, green / 10, blue / 10);
    for (int j = 1; j <= EyeSize; j++) {
      setPixel(NUM_LEDS - i - j, red, green, blue);
    }
    setPixel(NUM_LEDS - i - EyeSize - 1, red / 10, green / 10, blue / 10);

    FastLED.show();
    delay(SpeedDelay);
  }
  delay(ReturnDelay);
}

void LeftToRight(byte red, byte green, byte blue, int EyeSize, int SpeedDelay, int ReturnDelay) {
  for (int i = 0; i < NUM_LEDS - EyeSize - 2; i++) {
    setAll(0, 0, 0);
    setPixel(i, red / 10, green / 10, blue / 10);
    for (int j = 1; j <= EyeSize; j++) {
      setPixel(i + j, red, green, blue);
    }
    setPixel(i + EyeSize + 1, red / 10, green / 10, blue / 10);
    FastLED.show();
    delay(SpeedDelay);
  }
  delay(ReturnDelay);
}

void RightToLeft(byte red, byte green, byte blue, int EyeSize, int SpeedDelay, int ReturnDelay) {
  for (int i = NUM_LEDS - EyeSize - 2; i > 0; i--) {
    setAll(0, 0, 0);
    setPixel(i, red / 10, green / 10, blue / 10);
    for (int j = 1; j <= EyeSize; j++) {
      setPixel(i + j, red, green, blue);
    }
    setPixel(i + EyeSize + 1, red / 10, green / 10, blue / 10);
    FastLED.show();
    delay(SpeedDelay);
  }
  delay(ReturnDelay);
}

void theaterChase(byte red, byte green, byte blue, int SpeedDelay) {
  for (int j = 0; j < 10; j++) { //do 10 cycles of chasing
    for (int q = 0; q < 3; q++) {
      for (int i = 0; i < NUM_LEDS; i = i + 3) {
        setPixel(i + q, red, green, blue);  //turn every third pixel on
      }
      FastLED.show();

      delay(SpeedDelay);

      for (int i = 0; i < NUM_LEDS; i = i + 3) {
        setPixel(i + q, 0, 0, 0);    //turn every third pixel off
      }
    }
  }
}

void outsideinmeteors(){
  int myVar=random(0,3);
  switch (myVar) {
  case 0:
  red();
  break;

  case 1:
  blue();
  break;

  case 2:
  white();
}
}
void red(){ 
  //static uint8_t hue;
  for(int i = 0; i < NUM_LEDS/2; i++) {   
    // fade everything out
    leds.fadeToBlackBy(20);

    // let's set an led value
    leds[i] = CRGB(250,0,0);

    // now, let's first 20 leds to the top 20 leds, 
    leds(NUM_LEDS/2,NUM_LEDS-1) = leds(NUM_LEDS/2 - 1 ,0);
    FastLED.delay(random (2,30));
  }  
}

void blue(){ 
  //static uint8_t hue;
  for(int i = 0; i < NUM_LEDS/2; i++) {   
    // fade everything out
    leds.fadeToBlackBy(20);

    // let's set an led value
    leds[i] = CRGB(0,0,250);

    // now, let's first 20 leds to the top 20 leds, 
    leds(NUM_LEDS/2,NUM_LEDS-1) = leds(NUM_LEDS/2 - 1 ,0);
    FastLED.delay(random(2,30));
  } 
}

void white(){ 
  //static uint8_t hue;
  for(int i = 0; i < NUM_LEDS/2; i++) {   
    // fade everything out
    leds.fadeToBlackBy(20);

    // let's set an led value
    leds[i] = CRGB(250,250,250);

    // now, let's first 20 leds to the top 20 leds, 
    leds(NUM_LEDS/2,NUM_LEDS-1) = leds(NUM_LEDS/2 - 1 ,0);
    FastLED.delay(random(2,30));
  } 
}

Change:

case 9:
        outsideinmeteors;

To:

case 9:
        outsideinmeteors();
break;

default:
break;

No, that's not it. BTW I changed the case to 8.

     case 8:
     outsideinmeteors;
      break;

      default:
      break;

I even tried this

     case 8:
     outsideinmeteors;
      break;

      default:
      ;

Continues to freeze up. Seems to never get into the function. Both of the pasted snippets above compile.

Pay attention on ().

Whew!
Finally.
Works as expected. Thank you for sticking with me on this.
I was able to get rid of the 'default' function.

You should not remove the default case.

You should mark the post that helped you as solution, so someone can find the answer easily.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.