Sunday, May 30, 2010

Task 57 - Finding smallest Value With Suitable Message.

#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;



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


for (int i=0; i <10; i++){
photocellReading = analogRead(photocellPin);
if (photocellReading < smallest){
smallest = 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);
}

void loop(){
}

No comments:

Post a Comment