Reference   Language (extended) | Libraries | Comparison | Changes

EEPROM.write(address, value)

Description

Write a byte to the EEPROM.

Parameters

address: the location to write to, from 0 to 511 (int)

value: the value to write, from 0 to 255 (byte)

Returns

none

The Atmega 168 datasheet says that EEPROM memory has a specified life of 100000 write/erase cycles, so there is a limit to how many times you can write information to that memory space. Keep this in mind for long-lived projects or fast-moving data.

The datasheet also specifies that a write cycle takes 3.3 ms to complete. Other EEPROM write and read requests will fail if executed in this time period. This delay appears to be built into the EEPROM library as a casual test shows each cycle taking 3.33 ms to execute.

Hence, you do not specifically need to add a delay to an EEPROM write, just be aware of the built-in time delay.

Example

#include <EEPROM.h>

void setup()
{
  for (int i = 0; i < 512; i++)
    EEPROM.write(i, i);
}

void loop()
{
}

See also

Reference Home

Corrections, suggestions, and new documentation should be posted to the Forum.

The text of the Arduino reference is licensed under a Creative Commons Attribution-ShareAlike 3.0 License. Code samples in the reference are released into the public domain.