Previous information load

Is it possible to when Arduino power will on then it will load with previous information.

Did you mean to load some parameter at start which was previously saved? Then yes. It is possible with nonvolatile memory as EEPROM or SD card. Depends on which Arduino you have.

I am using Mega 2560. I automation my home. When the power off and on then all lights off then i switch on all lights again on my smart home. So want to know that collect previous lights on and off information then when power off and on load that information and lights on again automatically. :frowning:

Use EEPROM. You can find examples at File > Examples > EEPROM and more information at:

The idea is that you will assign an EEPROM address to each light. Any time you turn a light on or off you will save that state to its address in the EEPROM. In your setup() you will read the saved state from each light's EEPROM address and turn on/off the light accordingly. This will allow your system to return to its previous state after power outage.

You need to be careful not to write to the EEPROM addresses too frequently. They are only rated for 100000 writes. You'll never reach that with normal usage but if you have a bug in your code it could happen very quickly.

a better way (for the eeprom) is:
you hook up a 5V/1Farad Goldcap to the Arduino 5V.
if you use a 5V Powersupply, put a diode between PSU and Arduino.
Then take a digital IO and put it on the PSU side of that diode.
In your sketch you must always Pull this IO (as Input) and test if it is high.
If Power gets lost, the IO Pin will go low.
Now your Sketch takes notice of that IO Pin going low, you save all datas to eeprom!
Because of the 1Farad Goldcap you have enought time to save the states!
In your setup-routine you must read your datas back and set them.
A very longterm stable solution!

1Farad might overwhelm the power source for initial charging. Perhaps add a series resistor to limit the charge rate of the cap.

you're right, put in a 33Ohm Resistor or so. it reduces the power to 150mA