tylernt:
This page has read and write examples:
Arduino Playground - HomePage
Hi again, i took a look to your link and found this the most interesting "simple" code to use.
2012-07-30, Thijs Elenbaas
Using the EEPROMex library, the code would simplify to the following:
#include <EEPROMex.h>
// ID of the settings block
#define CONFIG_VERSION "ls1"
// Tell it where to store your config data in EEPROM
#define memoryBase 32
bool ok = true;
int configAdress=0;
// Example settings structure
struct StoreStruct {
char version[4]; // This is for mere detection if they are your settings
int a, b; // The variables of your settings
char c;
long d;
float e[6];
} storage = {
CONFIG_VERSION,
220, 1884,
'c',
10000,
{4.5, 5.5, 7, 8.5, 10, 12}
};
void setup() {
EEPROM.setMemPool(memoryBase, EEPROMSizeUno); //Set memorypool base to 32, assume Arduino Uno board
configAdress = EEPROM.getAddress(sizeof(StoreStruct)); // Size of config object
ok = loadConfig();
}
void loop() {
// [...]
int i = storage.c - 'a';
// [...]
storage.c = 'a';
if (ok)
saveConfig();
// [...]
}
bool loadConfig() {
EEPROM.readBlock(configAdress, storage);
return (storage.version == CONFIG_VERSION);
}
void saveConfig() {
EEPROM.writeBlock(configAdress, storage);
}
now, i really cant read this code and the explanation from the commands used in this lib is quite minimal. I already made my hour counter with success. the hours are stored in a value "Counter 1" does anybody knows what i have to do to use this code example to write the value of my "counter 1" to my adruino's eeprom and use it for further hour counting after a power switch off?
for the people who are interested my hour counter is build op as followed:
//hour counter
if (millis() - lastup == 360000){
lastup = millis();
Counter_01 = Counter_01 + 0.1;
Serial.print("Running hours: ");
Serial.println(Counter_01);
}
thank everybody for all the help so far. if we can just finish this last part i would be so happy!!
best regards