1
0
mirror of https://github.com/arduino/Arduino.git synced 2024-12-04 15:24:12 +01:00
Arduino/libraries/EEPROM/examples/eeprom_read/eeprom_read.ino

44 lines
889 B
Arduino
Raw Normal View History

2007-05-04 23:53:23 +02:00
/*
* EEPROM Read
*
* Reads the value of each byte of the EEPROM and prints it
2007-05-04 23:53:23 +02:00
* to the computer.
2010-02-24 04:49:48 +01:00
* This example code is in the public domain.
2007-05-04 23:53:23 +02:00
*/
#include <EEPROM.h>
// start reading from the first byte (address 0) of the EEPROM
int address = 0;
byte value;
void setup()
{
2012-04-11 12:56:31 +02:00
// initialize serial and wait for port to open:
2007-05-04 23:53:23 +02:00
Serial.begin(9600);
2012-04-11 12:56:31 +02:00
while (!Serial) {
; // wait for serial port to connect. Needed for Leonardo only
}
2007-05-04 23:53:23 +02:00
}
void loop()
{
// read a byte from the current address of the EEPROM
value = EEPROM.read(address);
2007-05-04 23:53:23 +02:00
Serial.print(address);
Serial.print("\t");
Serial.print(value, DEC);
Serial.println();
2007-05-04 23:53:23 +02:00
// advance to the next address of the EEPROM
address = address + 1;
2007-05-04 23:53:23 +02:00
// there are only 512 bytes of EEPROM, from 0 to 511, so if we're
// on address 512, wrap around to address 0
if (address == 512)
address = 0;
2007-05-04 23:53:23 +02:00
delay(500);
}