How can I generate huge list of random numbers in an array?

Hello, I am trying to generate a huge array of random numbers that stay the same every time the loop cycles. I want these random numbers in an array in before the void setup so that they don't change. So, the final code will appear only to be generating random numbers.

Is there an easier way to do this?

Imagine this code but with 1000 or 10000 random numbers in each array instead on 10:

byte Red[]={random(0,255),random(0,255),random(0,255),random(0,255),random(0,255),random(0,255),random(0,255),random(0,255),random(0,255),random(0,255),};
byte Green[]={random(0,255),random(0,255),random(0,255),random(0,255),random(0,255),random(0,255),random(0,255),random(0,255),random(0,255),random(0,255),};
byte Blue[]={random(0,255),random(0,255),random(0,255),random(0,255),random(0,255),random(0,255),random(0,255),random(0,255),random(0,255),random(0,255),};

Thanks.

You could assign sizes to the arrays and then use a for loop in setup() to actually assign the values.

But, which Arduino has room for 3000 or 30000 bytes?

There is an easy way. It's called a pseudo random sequence. Basically, it is a repeating sequence that appears completely random if you look at shorter parts of it.

/* Pseudorandom32 by Aarg 2015-05-24

 Turns on and off a light emitting diode (LED) connected to a
 pseudorandom shift register

 The circuit:
 * LED attached from pin 13 to ground.
 * Note: on most Arduinos, there is already an LED on the board
 */

const int ledPin =  13;      // the number of the LED pin
int ledState = LOW;             // ledState used to set the LED

unsigned long shiftRegister = 0xDEADBEEF;
unsigned long tempXor;

unsigned long previousMillis = 0;        // will store last time LED was updated

const long interval = 50;           // interval at which to blink (milliseconds)

void setup() {
  // set the digital pin as output:
  pinMode(ledPin, OUTPUT);
}

void loop()
{
  unsigned long currentMillis = millis();

  if (currentMillis - previousMillis >= interval) {
    previousMillis = currentMillis;

// get exclusive or feedback from tap 28 and 31, i.e. bit 27 and 30

    tempXor = (shiftRegister & ((unsigned long)1 << 30)) ^ ((shiftRegister << 3) & ((unsigned long)1 << 30));

    shiftRegister = shiftRegister << 1;
    
    //
    if (tempXor != 0)
    {
      ledState = HIGH;
      shiftRegister |= 1;
    }
    else
      ledState = LOW;

    // set the LED with the ledState of the variable:
    digitalWrite(ledPin, ledState);
  }
}

The sequence in this code is insanely long, but there are shorter sequences that you can use.

http://www.arduino.cc/en/Reference/RandomSeed

Every time you want the pseudorandom sequence to start again, just call randomSeed() with the same number.

aarg:
There is an easy way. It's called a pseudo random sequence. Basically, it is a repeating sequence that appears completely random if you look at shorter parts of it.

The sequence in this code is insanely long, but there are shorter sequences that you can use.

Oh cool, thank you!

MorganS:
http://www.arduino.cc/en/Reference/RandomSeed

Every time you want the pseudorandom sequence to start again, just call randomSeed() with the same number.

Oh ya, my bad. I figured out how to get a sequence of the same random numbers. I needed to nest it into another loop. Thanks.

Casey7346:
Oh ya, my bad. I figured out how to get a sequence of the same random numbers. I needed to nest it into another loop. Thanks.

Right, you can reseed the generator. Also that way, you can have an arbitrary sequence length. The pseudorandom method always has a cycle of 2^n-1. At least, the basic algorithm does. The advantage is in simplicity. It's easy to build one in hardware using logic gates and a shift register IC.