Reference   Language | Libraries | Comparison | Changes

EEPROM

write()

Description

Write a byte to the EEPROM.

Syntax

EEPROM.write(address, value)

Parameters

address: the location to write to, starting from 0 (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.

This reference is licensed under a Creative Commons Attribution-ShareAlike 3.0 License and is based on the Arduino reference. Code samples in the reference are released into the public domain.