Tuesday, May 18, 2010

Random numbers on the serial screen.

//Generating random numbers on the serial screen.

long randNumber;

void setup(){
Serial.begin(9600);

randomSeed(analogRead(0)); //shuffles the random numbers
}

void loop() {
// print a random number from 0 to 299
randNumber = random(300);
Serial.println(randNumber);

// print a random number from 10 to 19
randNumber = random(10, 20);
Serial.println(randNumber);

delay(50);
}

No comments:

Post a Comment