I want to save different values on address 0 and 1 on eeprom I tried to change it but when I put data on address 0 and also put data on address 1 the address 0 change its value stored into random number and vice versa .. Is it possible to change the value of respective address without affecting others ..
CODE
in the setup
int eepromSize=EEPROM.length();
Serial.print("EEPROM found, size=");
Serial.println(eepromSize);
// Get the last fade value (as an integer)
EEPROM.get(0, WATEREQFORN1);
Serial.print("Last Value N1: ");
Serial.println(WATEREQFORN1);
EEPROM.get(1, WATEREQFORN2);
Serial.print("Last Value N2: ");
Serial.println(WATEREQFORN2);
The user will input the value that will be save in eeprom i use switch because the user will input like this example .. 100A or 23B
case 'A':
Serial.print("Case A got ");
Serial.println(val);
WATEREQFORN1 = val;
EEPROM.put(0, WATEREQFORN1);
Serial.print("DATA SAVE TO EEPROM");
break;
case 'B':
Serial.print("Case B got ");
Serial.println(val);
WATEREQFORN2 = val;
EEPROM.put(1, WATEREQFORN2);
Serial.print("DATA SAVE TO EEPROM");
break;
The problem is, when I change/write value into address 0 and after that change/write also into address 1 the value on address 0 also change into different random numbers.
WATEREQFORN1
andWATEREQFORN2
? You only show a bit of your code, and have omitted what may be the most important parts - your variable definitions.unsigned int WATEREQFORN1; unsigned int WATEREQFORN2;
That is the value the user enter sir .. example200A
it will be get bycase a
and be assign inWATEREQFORN1
as show in my codeWATEREQFORN1 = val
theval
initially hold the serial value200
and pass toWATERECFORN1