Friday, March 12, 2010

Task 36 - Random Numbers with Mean

// Adam Randall - Random Numbers Program, generates 100 random numbers between 1 and 10 and display mean.

long randNumber;
int total;
int mean;

void setup(){
total =0;
mean =0;
Serial.begin(9600);
randomSeed(analogRead(0));
for (int i=0; i<100; i++){
randNumber = random(0, 10);
Serial.print(i);
Serial.print(": ");
Serial.println(randNumber);
total = total + randNumber;
delay(500);
}
mean = (total/100);
Serial.println ("The Mean is: ");
Serial.print(mean);
}

void loop() {
}

No comments:

Post a Comment