EEPROM_writeAnything problem
hi,
i'have made test file when run it gives 2 lines on lcd display
-----------------------
1024 (correct)
0 (not correct should 1024)
-----------------------
i don't eeprom_reedanything working. can @ code , please me solve it.
i use arduino 0019.
i'have made test file when run it gives 2 lines on lcd display
-----------------------
1024 (correct)
0 (not correct should 1024)
-----------------------
i don't eeprom_reedanything working. can @ code , please me solve it.
i use arduino 0019.
code: [select]
#include <eeprom.h>
#include <liquidcrystal.h>
liquidcrystal lcd(12, 11, 5, 4, 3, 2);
template <class t> int eeprom_writeanything(int ee, const t& value)
{
const byte* p = (const byte*)(const void*)&value;
int i;
for (i = 0; < sizeof(value); i++)
eeprom.write(ee++, *p++);
return i;
}
template <class t> int eeprom_readanything(int ee, t& value)
{
byte* p = (byte*)(void*)&value;
int i;
for (i = 0; < sizeof(value); i++)
*p++ = eeprom.read(ee++);
return i;
}
long lengte;
struct config_t
{
long lengte;
} cfg;
void setup(){
lcd.begin(16, 2);
lengte = 1024;
eeprom_writeanything(0, cfg);
delay(20);
eeprom_readanything(0, cfg);
delay(20);
lcd.clear();
lcd.print(lengte);
lcd.setcursor(0,1);
lcd.print(cfg.lengte);
delay(500);
}
void loop(){
}
Arduino Forum > Forum 2005-2010 (read only) > Software > Syntax & Programs > EEPROM_writeAnything problem
arduino
Comments
Post a Comment