You are on page 1of 2

/* This program takes input from two analog sensors and stores it on the arduino's EEPROM for later

recovery by another program designed to read and display the data in a comprehensible way*/ #include <EEPROM.h> // inludes the library for the eeprom int analogPin1=0; int analogPin2=1; int light=0; int therm=0; int address1=0; data int address2=1; data // // // // // tells the program what to call pin 0 tells the program what to call pin 1 stores retrieved number from light sensor stores retrieced number from temp sensor used to increment the write address of light

// used to increment the write address of temp

//starts serial monitor void setup() { Serial.begin(9600); } void loop() { // reads the analog number (from 0-1023) and stores it in // variable than makes clear what sensor the data comes from light=analogRead(analogPin1); therm=analogRead(analogPin2); // prints "Thermistor = 'therm value'" Serial.print("Thermistor = "); Serial.println(therm); // print "Photoresistor = 'light value'" Serial.print("Photoresistor = "); Serial.println(light); Serial.println(" "); // maps the analog number to one the EEPROM can stores in a byte light= map(light, 0, 1023, 0, 255); therm= map(therm, 0, 1023, 0, 255); // if the number of the address the program is currently on // is not the max for the EEPROM the program writes the value // of the given sensor to the current EEPROM address if(address1<511 || address2<511) { EEPROM.write(address1, light); EEPROM.write(address2, therm);

// increments the address location by 2 so they do not // overwrite each-other address1=address1+2; address2=address2+2; } // delays the readings by 10 minutes so that it can measure the // light an temperature data all day without running out of space delay(600000); }

You might also like