Arduino: How to Read and Write EEPROM values
When you reset an Arduino, the state of any variables you might have will be lost. So what if you want to keep a value even after it’s been powered off? Luckily, ATmega chips have an area of memory called EEPROM, or “Electrically Erasable Programmable Read-Only Memory.” This allows you to store persistent values, and Arduino ships with an EEPROM library that makes it easy to use.
Here’s an example Arduino sketch that demonstrates how to read from and write to this part of memory: