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.
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(){

}

did mean
code: [select]
cfg.lengte = 1024;
 eeprom_writeanything(0, cfg);

or
code: [select]
lengte = 1024;
 eeprom_writeanything(0, lengte);

?


Arduino Forum > Forum 2005-2010 (read only) > Software > Syntax & Programs > EEPROM_writeAnything problem


arduino

Comments

Popular posts from this blog

CAN'T INSTALL MAMBELFISH 1.5 FROM DIRECTORY - Joomla! Forum - community, help and support

error: expected initializer before 'void'

CPU load monitoring using GPIO and leds - Raspberry Pi Forums