The Arduino microcontrollers have non volatile EEPROM memory built in. The EEPROM library allows you to read and write those bytes.

EEPROM Sizes:

1024 bytes

ATmega328

512 bytes

ATmega168
ATmega8

4KB (4096 bytes)

ATmega1280
ATmega2560. 

Using The Library

Note that you read and write one byte at a time – there is not an array read and write function.

Default eeprom values are 0xFF.


#include <EEPROM.h>

  BYTE value;
  BYTE address;

  address = 0
  EEPROM.write(address++, 0x50);
  EEPROM.write(address++, 0x51);

  address = 0
  value = EEPROM.read(address++);
  value = EEPROM.read(address++);