
I’ll show you a real example using an Arduino Uno board and 4 LEDs connected to digital pins (with 220 Ohm resistors). Complete application code: Save a value given by a user to blink a LED If you have saved a number that requires more than one byte (ex: double), then you’ll need to read all the addresses for this number, and reconstruct the number back with all the bytes. You can read from EEPROM as much as you want without any problem. Note that the 100 000 rule is only for writing. The values will still be there, and reading them is quite easy. If you just write to EEPROM in the loop() function with no other code, you might destroy your EEPROM storage pretty fast.Īfter you’ve written some values to the EEPROM, you can now reboot your Arduino or simply reset your program. Remember, you only have about 100 000 write cycles available per address. Don’t write a value to the EEPROM inside an infinite loop without any delay or check for user input.

Also, that means that you can only store 1024/4 = 256 double values in the EEPROM memory. For example, a double value in Arduino Uno takes 4 bytes. So, for numbers between 0 and 255, that’s fine, but for other numbers you’ll have to split the number in several bytes, and store each byte separately.
HOW TO CHANGE PREFERENCES TO LET ARDUINO SAVE FILES HOW TO
You are learning how to use Arduino to build your own projects?Ĭheck out Arduino For Beginners and learn step by step.įirst, you have to include the EEPROM library at the top of your file. This memory is really suited for small values, for example a default settings to apply on boot, or a user preference. So, don’t expect to store a camera output, or even an image on the EEPROM memory.

To store numbers on multiple bytes ( int, long, double, …) you need to know how many bytes each value will take, so you can space the values accordingly in the memory.That’s why you need to manipulate this memory with precautions. After about 100 000 write operations, the memory location might be dead.

