I want to know the purpose of using the EEPROM because I can't get it, I mean I know that it can store values for a long time, but I just can't get the goal here
#include<EEPROM.h>
void setup()
{
Serial.begin(9600);
EEPROM.write(0,4);
int s=EEPROM.read(0);
int f=10;
Serial.print(s);
Serial.print(" ");
Serial.print(10);
}
void loop() {}
For example, I'm using EEPROM to see the difference if I print a value inside variable s
to the serial moniter using EEPROM and a normal value inside the variable f
.
But I couldn't find the difference between both because when unplugging the power and turn it on again, both of them are printed.
Hope you got the idea and I hope to see some feedback.
Thank you..
the LED program
then I made this program that will compare the EEPROM value to num.4 and compares the F variable to num.4 known that both F and the EEPROM values are 4. and then I changed both of the values to 3. shouldn't the GREEN LED of the EEPROM still on because it has already stored num.4??
#include<EEPROM.h>
void setup()
{
pinMode(12,OUTPUT);
pinMode(11,OUTPUT);
}
void loop()
{
EEPROM.write(0,4); //GREEN LED
int f=4; //RED LED
if(EEPROM.read(0)==4) digitalWrite(12,HIGH);
if(f==4) digitalWrite(11,HIGH);
}
setup()
? The entire code that is inloop()
? Do you understand what Tom_C wrote in his answer? ONE sketch is not enough to really demonstrate the purpose of an eeprom. Instead you should upload and run a sketch1 which writes a value to eeprom insetup()
, then upload and run a sketch2 which reads the eeprom and uses the respective value