#include EEPROM.h
int photocellPin = 0; // the cell and 10K pulldown are connected to a0
int photocellReading;// the analog reading from the analog resistor divider
int value;
int a = 0;
int smallest = 0;
int biggest = 0;
float average = 0;
void setup() {
Serial.begin(9600);
for (int i=0; i <10; i++){
photocellReading = analogRead(photocellPin);
if (photocellReading < smallest){
smallest = photocellReading;
}
if (photocellReading > biggest){
biggest = photocellReading;
}
average = average + photocellReading;
EEPROM.write(i, photocellReading);
delay(500);
}
for (int i=0; i <10; i++){
value = EEPROM.read(a);
Serial.print(a);
Serial.print("\t");
Serial.print(value);
Serial.println();
a = a + 1;
if (a == 10){
a = 0;
delay(500);
}
}
Serial.println("The Smallest Value Was: " + smallest); // displays smallest value
Serial.println("The Biggest Value Was: " + biggest); // displays biggest value
average = average/10; // calculates mean
Serial.println("The Average/Mean Was: " + average); // displays average value
}
void loop(){
}
Sunday, May 30, 2010
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment