The random()
function can be used to generate pseudo-random numbers:
void setup() {
Serial.begin(9600);
}
void loop() {
long randomNumber = random(500); // Generate a random number between 0 and 499
Serial.println(randomNumber);
randomNumber = random(100, 1000); // Generate a random number between 100 and 999
Serial.println(randomNumber);
delay(100);
}