How to save data in arduino when it's power goes off 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???
Look up EEPROM. it is a memory that saves content even though power is off. 

You can write data in EEPROM and when power comes back read it back.

there are safe ways to write in EEPROM without corrupting it.