Save Values in Your Arduino's Permanent Memory

26K303

Intro: Save Values in Your Arduino's Permanent Memory

********************Although the Arduino Code works fine, Some Info in this Instructable is not "Entirety" correct , please also read the comments**********************

This is a really short instructable, I never knew you could do this, actually I assumed that its not possible, until I recently found that I was wrong, So I thought of sharing this with you.

The arduino has 512 memory address spaces where you can write data to, This means you can write a string of 512 characters to it. You basically write an ASCII Character's ASCII Decimal value to it.

The arduino IDE comes standard with a EEPROM library.

All you you have to do is include it.

#include <EEPROM.h>

Then simply write your value to it.
Say I want to write my name to the Arduino's EEPROM.
I would convert each character in my name "MARTIN" to ASCII Decimal values.
I.E

M = 77<br>A = 65
R = 82
T = 84
I = 73
N = 78
void setup()<br>{
//EEPROM.write(ADDRESS,VALUE);<br>int MyVal=255;
	EEPROM.write(0,77);<br>	EEPROM.write(1,65);
	EEPROM.write(2,82);<br>	EEPROM.write(3,84);<br>	EEPROM.write(4,73);<br>	EEPROM.write(5,78);
}

STEP 1: Read the Values From Memory

You can then simply read the values again using a for loop
Try this after you switched off the Arduino and on again. It will print your saved values to the Serial Monitor
If you want, check out this thread

http://techtinker.co.za/viewtopic.php?f=23&t=16

Its got some more detail about ASCII codes if you are not familiar with it.

#include <EEPROM.h><br>int MemoryAddr=0;<br>int Value=0;<br>void setup()<br>{<br>Serial.begin(38400);<br>}<br>
void loop()<br>{
  
  for (int MemoryAddr=0; MemoryAddr <= 5; MemoryAddr++) 
  {
  value = EEPROM.read(MemoryAddr);
  char MyCharacter = char(value);
  Serial.println(MyCharacter);  
  }  
 delay(5000); 
}

3 Comments

Nicely done. Thanks for sharing this!

Thanks Awesome, for the info So actually i had it wrong the UNO can then save 1024 characters :-), Ive updated the instructable for future reference, thanks for contributing

Hey, I didn't know you could do that. Thanks for this instructable!

A check on the Arduino official website shows a couple of useful tips...

From: http://arduino.cc/en/Reference/EEPROM

The EEPROM memory has a specified life of 100,000 write/erase cycles, so you may need to be careful about how often you write to it.

The microcontrollers on the various Arduino boards have different amounts of EEPROM:

1024 bytes on the ATmega328

512 bytes on the ATmega168 and ATmega8

4096 bytes on the ATmega1280 and ATmega2560.