Go Down

Topic: Retaining Variable Value in Arduino - Possible? (Read 1 time) previous topic - next topic

Gedon

Is there a way for a Variable declared in the program to retain it's value if it is change and the arduino is turned off then on again?

Example is that if "X" variable is declared as 0 from the start of the program, and then it became "X=1", is it possible when you turn off/on the arduino
the "X" retains it value change which is "1" ?

billroy

No.  But you can store values in EEPROM and read them after a reboot.

Search the forum/playground for EEPROM and you'll find many examples.

-br

PaulS

EEPROM can be use for persistent storage. It has a finite number of write cycles, so you need to be judicious about when you write to it.


Gedon

Just a quick question to make sure, in the topic of powering the arduino,
HOW MUCH VOLTAGE WOULD YOU NEED TO TURN ARDUINO UNO ON IF NOT CONNECTED TO A PC via Cable?

Arrch


liudr

I use a 9V center positive ac adapter with 1A current rating. Make sure it is center positive.

dnear1

Another possibility is check the peripheral chips you're using.  Sometimes they offer a place to stash a few bytes.  For instance, I use the DS1305 RTC in one of my projects.  it has 96 bytes of user RAM that is battery-backed.  No finite cycles to worry about.  I think the DS1307 and others have similar.  You could also consider adding a Serial ROM chip.

Gedon

It seems that EEPROM only gives you a max of 256 value to store in each address.

IS THERE ANYWAY OF INCREASING IT TO 1000?

PaulS

Quote
IS THERE ANYWAY OF INCREASING IT TO 1000?

No. You can however store each byte of an int, and later reconstruct it. Look at highByte() lowByte() and word().

Go Up