Hi, im making a lcd thermometer with the ability of save the actual temperature on the eeprom.
when i press a button, it was designed to write in eeprom the actual temperature and print saved on lcd (all things was in portuguese on the code)
the problem is when i call eeprom.write, it writes the temperature for infinite.
here is the actual code, based on thermistor code found on arduino playground:
#include <LiquidCrystal.h>
#include <EEPROM.h>
#include <math.h>
int addr = 0;
int es = 0;
LiquidCrystal lc(12, 11, 5, 4, 3, 2);
double Thermister(int RawADC) {
double Temp;
Temp = log(((10240000/RawADC) - 10000));
Temp = 1 / (0.001129148 + (0.000234125 + (0.0000000876741 * Temp * Temp ))* Temp );
Temp = Temp - 273.15; // Convert Kelvin to Celcius
//Temp = (Temp * 9.0)/ 5.0 + 32.0; // Convert Celcius to Fahrenheit
return Temp;
}
void setup() {
lc.begin(16,2);
lc.print("Temperatura");
lc.setCursor(14,0);
lc.print("oc");
lc.setCursor(0,1);
lc.print("2011");
lc.print(" Allan");
}
void loop() {
lc.setCursor(12,0);
lc.print(int(Thermister(analogRead(0)))); // display Fahrenheit
delay(100);
es = digitalRead(A1);
if (es == HIGH) {
EEPROM.write(addr, (int(Thermister(analogRead(0)))));
lc.setCursor(0,1);
lc.print(" ");
lc.print("Salvo");
delay(1000);
lc.print("");
lc.print("Allan");
}
addr = addr + 1;
if (addr == 512)
addr = 0;
}
Thanks