24 March 2010

Task 34 - 100 random numbers between 0-9 on Serial Monitor


/*
* Project: Random-numbers_task_34
* Author: Jane-Maree Howard
* Date: Wednesday 24/03/2010
* Platform: Arduino 18
* Purpose: To generate 100 random numbers from 0-9 inclusive,
* & output them to the Serial Monitor (SM)
*/

long randNumber; //random number to SM

//set up random number seed & baud rate to SM
void setup()
{
Serial.begin(9600);
randomSeed(analogRead(0));
}//end setup()

//generates 100 random numbers 0-9 inclusive
void loop()
{
Serial.println("\n100 random numbers");

for (int j=1; j<=100; j++)
{
randNumber = random(10); // random number from 0-9
Serial.println(randNumber);
delay(10);
}//for (j++)

delay(500);
}//end loop()


No comments:

Post a Comment