LED Strip, random pattern and color

So this is a two part question. I'm very new to coding and have been mostly copy pasting my functions with a very basic understanding of how they work.

Problem 1:

I would like to randomly select a pattern from a predefined list of patterns. I have been reading up on arrays but i'm not sure how to make it work for my functions.

Problem 2:

I would like each pattern to randomly select a color from a list of colors.

Essentially, I would want this to cycle through the random patterns with random predefined colors.

Here is the code without the actual pattern functions (Exceeds character limit)

#include "FastLED.h"
#define NUM_LEDS_A 37
#define NUM_LEDS 37
CRGB strip[NUM_LEDS_A];
#define PINA 6
#define BRIGHTNESS 30

void setup() {
FastLED.addLeds<NEOPIXEL, PINA>(strip, NUM_LEDS_A);
FastLED.setBrightness(BRIGHTNESS);

}

void loop() {

//list of function commands that cause a pattern

TwinkleRandom(500, 10, false);
Twinkle(255, 0, 0, 50, 50, false);
NewKITT(255, 0, 0, 2, 10, 50);
Strobe(255, 0, 0, 10, 50, 10);
FadeInOut(255, 0, 0);//red
CylonBounceLong(0, 0, 255, 4, 10, 100, 5); // blue
MeteorRain(255,255,0,2, 64, true, 10);//yellow
RunningLights(255,0,0,50); //RED
colorWipe(0,255,0, 10);
rainbowCycle(10);
theaterChase(255,0,0,50);
}

That looks very much like the FastLED demo example. It contains a list of patterns that are accessed in sequence. If you use the random() function, I'm sure you can figure out how to select one of the patterns randomly.

The same principle can be applied to the selection of the color for the given pattern.

So in the linked post from AWOL I was able to use the "switch / case" structure to randomly select the patterns.

Now I am trying to follow the advice of Grumpy_Mike from the same post on how to randomly select the colors for each pattern.

The problem I'm encountering is I have no idea how to set up an array that would work.

this is the closest I have come:

#include "FastLED.h"
#define NUM_LEDS_A 37
#define NUM_LEDS 37
CRGB strip[NUM_LEDS_A];
#define PINA 6
#define BRIGHTNESS 30

void setup() {
  FastLED.addLeds<NEOPIXEL, PINA>(strip, NUM_LEDS_A);
  FastLED.setBrightness(BRIGHTNESS);

  
}
// declare structure for rgb variable
struct rgbcolor {
  byte r;    // red value 
  byte g;   // green value
  byte b;   // blue value
} someColors[] = {
  { 255 , 0 , 0 }, // orange value
  { 0, 255 , 0 }, // red value
  { 0 , 0 , 255}, // magenta value
  };

void loop() {
  
  int whichColor = random(someColors);
  
Strobe (someColors[whichColor].r , someColors[whichColor].g , someColors[whichColor].b , 40, 50, 10); // red,  green,  blue,  StrobeCount,  FlashDelay,  EndPause

This is now choosing a random code from the array for each of the rgb values, but they are not on the same row as each other. so I'm getting a lot of whites or LEDS off.

When posting code you must post all of it so we can reproduce it ourselves and try and track down the problem.

To set up an array see:- array - Arduino Reference

Note you will want a separate array for each colour component or a two dimensional array to hold all values.

Okay. I didn't post it all because it exceeded the character limit. Here it is.

I've also read up on arrays and how to build them, the problem I'm encountering is I want to pull 3 variables from the array using one command. It seems like the only way to have an array with all three variables is to use a multi dimensional array and somehow pull the entire row. but I don't know how to exactly perform that.

In the code right now it is pulling a variable for each of the Red, Green, and Blue variables from different rows. Giving me mostly white colors.

Thanks for your help!

Flagpole_Eyes_Testing.ino (14.8 KB)

In the code right now it is pulling a variable for each of the Red, Green, and Blue variables from different rows. Giving me mostly white colors.

This is a common issue when trying to create random colors,
2 options, 1 create a 1 dimensional array holding colors that you have actually pre-defined which is what you did in reply #2 except that this line int whichColor = random(someColors); should probably just be int whichColor = random(3); since your array is only holding 3 different colors for now
the other option is to do a fully random color choice where you can either make use of FastLED HSV color.
Or choose first which color you want to determine the 'whitenss' then choose a halfway point between the 2 other colors and then choose a value for the whitenss.

I would do it this way:-
remove:-

// declare structure for rgb variable
struct rgbcolor {
  byte r;    // red value 
  byte g;   // green value
  byte b;   // blue value
}

and change what follows to :-

randomSeed(analogRead(0));
someColors[3][] = {
  { 255 , 0 , 0 }, // orange value
  { 0, 255 , 0 }, // red value
  { 0 , 0 , 255}, // magenta value
  };

Then use

void loop() {

byte whichColor = random(0,3);

Strobe (someColors[0][whichColor] , someColors[1][whichColor] , someColors[2][whichColor] , 40, 50, 10); // red,  green,  blue,  StrobeCount,  FlashDelay,  EndPause

//The following is a switch case which chooses one pattern at random.
switch (17)

No it dosn't but

//The following is a switch case which chooses one pattern at random.
switch (random(14))

would.

I was trying to see if there was a a way to use FastLED CRGB struct efficiently to do what you want. (adafruit_neopixel has a 32-bit color input/output) And it does, now let's see if i can work out how to use it.
from pixeltypes.h

/// allow construction from 32-bit (really 24-bit) bit 0xRRGGBB color code
    inline CRGB( uint32_t colorcode)  __attribute__((always_inline))
    : r((colorcode >> 16) & 0xFF), g((colorcode >> 8) & 0xFF), b((colorcode >> 0) & 0xFF)

i think it would be something like thisCRGB colors[] = {CRGB(0xFF0000), CRGB(0x00FF00), CRGB(0x0000FF)}; and now you can access the colors you want like.