Looking for some guidance on how to modify and store a single int value.

Hey everyone!

First time posting on this forum. I had a look around to try and inquire about a resolution to my question without having to post it directly, but no such solution presented itself.

I am looking to create a little piggy bank for all my coins. You would place a few coins in, and enter the value of the coins you added onto a keypad, and it would display the total amount of money in the bank on an LCD display. When you power the Arduino (and the display) off and then back on, it would give a little booting message, and then display the amount of money in the bank.

My question is this:

How would I store this single value? How would I code it such that when I power the device on and off, it would still display the total value of the bank, even after the previous deposit/withdrawal?

Thanks in advance for any advice/help!

jableselduderino

Store the value in EEPROM. In your setup() you will read from the EEPROM address and set the variable. Whenever the value changes you write that value to EEPROM. See: