Language | Libraries | Comparison

randomSeed(seed)

Description

This allows you to place a variable into your random number generator, which helps it to generate "random" numbers. There are a variety of different variables you can use in this function. Commonly used are current time values (using millis() ), but you could also try something else like user intervention on a switch or antennae noise through an analog pin.

Parameters

long, int - pass a number to generate the seed.

Returns

no returns

Example

long randNumber;

void setup(){
  Serial.begin(19200);
}

void loop(){
  randomSeed(analogRead(0));
  randNumber = random(300);
  Serial.println(randNumber);
}

See also

Reference Home Reference Home

Corrections, suggestions, and new documentation should be posted to the Forum.