How to Save Value from Counter to EEPROM in Arduino Uno [solved]

sterretje:
put() and get() work basically like write() and read(); the difference is that you don't have to worry about the type of the variable. You're storing an int but when using write you only write half of that information; some for the read.

put example

...

...
int sensorCounter = 5;
...
...

void setup()
{
    Serial.begin(9600);
    // save sensor counter
    EEPROM.put(0, sensorCounter);
    Serial.print("sensorCounter value ");
    Serial.print(sensorCounter);
    Serial.println(" saved to eeprom");
}

void loop()
{
}



**get example**


...
...
int sensorCounter = 0;
...
...

void setup()
{
    Serial.begin(9600);
    // read sensor counter
    EEPROM.get(0, sensorCounter);
    Serial.print("retrieved sensorCounter: ");
    Serial.println(sensorCounter);
}

void loop()
{
}




Not tested but should give the idea.

thank you mate, ill try :slight_smile: