Language | Libraries | Comparison
The random function allows you to return pseudo-random numbers for use in your applications. NOTE: Use this after using the randomSeed() function.
min - optional starting range (ie: from "50" - 300).
max - the overall range of random numbers you'd like returned.
long - returns the random number.
long randNumber; void setup(){ Serial.begin(19200); } void loop(){ randomSeed(analogRead(0)); // return a random number from 50 - 300 randNumber = random(50,300); // example with only a range, which would return // a number between 0 - 300 // randNumber = random(300); Serial.println(r); }
Corrections, suggestions, and new documentation should be posted to the Forum.