# Randomize functions called

Hello, I am trying to wrap my head around the problem of being able to randomize functions called. I have a list of functions that need to run at random. There is no time limitation as for how long the randomizer will continue, essentially, the max would be around 1000 iterations. I need to be able to randomly pick a function, execute it and return values to the board. I think that in order to randomize functions they need to be able to return same type of values and some of my functions return different type of values. Here is the list of functions i need to randomize. Thank you for the help in advance!

//list of function commands that cause a pattern with types of values return

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);
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);

The simplest solution I can think of would be to get a random number, and then decide which function to call based on that number. For example:

``````long randNum = random(0, 1200);
TwinkleRandom(500, 10, false);
} else if(radNum <= 200) {
Twinkle(255, 0, 0, 50, 50, false);
} // etc for every function
``````

Also, don’t forget to call randomSeed() with some seed (e.g. analogRead(0)) before calling random().

some of my functions return different type of values

What types do they return?

/list of function commands that cause a pattern with types of values return

I don't see anything concerning return types

UKHeliBob:
I don't see anything concerning return types

That's because those functions don't return anything.

PaulS:
That's because those functions don't return anything.

How can you tell ?

UKHeliBob:
How can you tell ?

Because I have LED strips, and I've seen that code. It's an example from the FastLED library.

Looks like a duplicate thread LED Strip, random pattern and color - Programming Questions - Arduino Forum

UKHeliBob:
Looks like a duplicate thread https://forum.arduino.cc/index.php?topic=618544.0

Well, yeah, there was that.