Libraries \ EEPROM

Reference for Wiring version 1.0 Build 0100+ If you have a previous version, use the reference included with your software. If see any errors or have any comments, let us know.



#include "EEPROM.h"

char val;

void setup() {
  if ( != 'H') {  // If an 'H' hasn't been stored before
                               // in the EEPROM address 5
    EEPROM.write(5, 'H');      // store an 'H' in EEPROM address 5
  val =;        // read value stored in EEPROM address 5

  pinMode(48, OUTPUT);

void loop() {
  // if val is 'H' then turn ON the onboard LED (pin 48)
  if ( val == 'H' )             
    digitalWrite(48, HIGH);
Description EEPROM stands for Electrically Erasable Programmable Read Only Memory. It is a special kind of memory that retains its contents even when the power on the I/O board is turned off. The Wiring I/O board has 4K bytes of data EEPROM memory, which is a separate data space in which single bytes can be read and written. The EEPROM has an endurance of at least 100,000 write/erase cycles, which is not difficult to attain if you write data to it in a for loop, so special care has to be taken to avoid doing it by mistake. The EEPROM is ideal to store data that doesn't change that often, like permanent message strings, or configuration for an application, etc. The EEPROM data bytes are addressed linearly between 0 and 4095.
Returns None
Usage Application
Updated on July 07, 2011 11:09:49pm PDT

Creative Commons License