Random Numbers



random is part of the Standard Library. Random will return an int. You can pass this function either 1 or 2 arguments. If you pass just one, it will return a random number between 0 (inclusive) and the number you passed in (exclusive). Passing in two numbers will return a random number between the min (inclusive) and max (exclusive).

Run this sketch a few times:
void setup(){
    Serial.begin(9600);
}
void loop(){
   int n=random(2,10);
   Serial.println(n);
   delay(500);
}
Do you notice anything funny?