I am doing a project 'arduino based switch operation'. Here the user needs to set a time to turn on relay and set time to turn it off. The problem is that I want to supply power to arduino using adapter connected to the ac supply (where the relay will also be connected). When the on time is set and if power goes off for some time then this system doesn't work. I want to save the data in arduino so that it will retain the data if power comes back.. So that my relay is operated on time.. How to do it guys???
Beside Georgi's answer, I would like to tell you some details.
a microcontroller can have a built-in EEPROM like the ATMega328 inside an Arduino UNO/Nano/mini, if not you would need to attach an external one, it can have may interfaces like SPI or IIC etc...
an EEPROM can hold only a specified amount of data, it can be 512byte like one on the ATMega328 microcontrollers, it can be only 64byte on others.
an EEPROM have addresses so for example in 8-bit EEPROM one address can hold only 8bits so values from (0-255) like on the ATMega328
Fourth : how to use it
In the beginning of your code you should first include the eeprom library
Then you would for example assign value "24" to one of the address on the EEPROM let's say address "1"
So you will use
Of course you can power off you board and repower it again and that particular address will have the assigned 8-bit value "24".
To read back
I hope that might help you or anyone else.
And as a side note an EEPROM have defined write and read cycles ~10000 maybe ~100000 after that amount it May not work.
Original documentation : here