Arduino Programming Language: RandomSeed

Name

randomSeed()

Description

Sets the seed value for random(). By default, random() produces different results each time the program is run. Set the value parameter to a constant to return the same pseudo-random numbers each time the software is run.

Syntax

randomSeed(value);

Parameters

value: (number to generate the seed)

  • int or long

Returns

none 

Usage

Application

Examples

long randNumber;

void setup(){
Serial.begin(9600);
randomSeed(analogRead(0));
}

void loop(){
randNumber = random(300);
Serial.println(randNumber);

delay(50);
}

Related Functions


Based on the reference originally written by Arduino Community,  wiring.org.co and  arduino.cc