Hardware Reference
In-Depth Information
the ATmega328 in the Uno has 1,024 bytes. The ATmega1280 and ATmega2560
used in the different versions of the Arduino Mega both have 4 KB of EEPROM.
The EEPROM Library
The EEPROM library is a collection of routines that can access the internal
EEPROM memory, reading and writing bytes. The EEPROM library can be
imported by manually writing the include statement:
#include <EEPROM.h>
Optionally, you can add the EEPROM library using the Arduino IDE. Go to
the Sketch menu item; select the Import Library submenu, and select EEPROM.
This automatically includes the library, as shown in Figure 6-2.
Figure 6-2:
Importing the EEPROM library
Reading and Writing Bytes
The entire EEPROM library consists of two functions:
read()
and
write()
.
These two functions can read and write bytes from specii c memory locations.
The
read()
function reads data from a specii ed address
adr
, expressed as
an
int
, and returns data as a
byte
.
EEPROM.read(adr);
Search WWH ::
Custom Search