In other code, we showed you how to write data to EEPROM so it will stay after you remove power. Now you need to read the data you stored. This works best when you combine a sensor input with the EEPROM Write so you can create a data logger. If you add a button to tell the Arduino when to read the data, you can combine a sensor collection, data write, and data read all into one program.
#include <EEPROM.h>
// start reading from the first byte (address 0) of the EEPROM
int address = 0;
byte value;
void setup() {
Serial.begin(9600);
while (!Serial) {
; // wait for serial port to connect. Needed for native USB port only
}
}
void loop() {
value = EEPROM.read(address);
Serial.print(address);
Serial.print("\t");
Serial.print(value, DEC);
Serial.println();
address = address + 1;
if (address == EEPROM.length()) {
delay(999999);
address = 0;
}
delay(10);
}