SummaryEEEPROM (External EEPROM) library supports external I2C EEPROMs. Include#include <EEEPROM.h> ClassesEEEPROM(int address) Support I2C EEPROM. Address is I2C memory address (settable using memory pins, read your EEPROM datasheet). MethodsReads one byte from EEPROM. Example #1 void EEEPROM::write(unsigned int address, byte value)Write byte to EEPROM. Example #1 #include <Wire.h>
#include <EEEPROM.h>
// Define new external EEPROM
EEEPROM memory(0xBA);
void setup()
{
// Start UART
Serial.begin(9600);
// Start I2C
Wire.begin();
// Write to 14th byte
memory.write(14, 123);
// 14th byte in 0xBA EEPROM is 123
}void EEEPROM::readPage(unsigned int address, byte *data, int length)Read page from EEPROM. Page size should be max. 30 bytes. Example #1 #include <Wire.h>
#include <EEEPROM.h>
// Define new external EEPROM
EEEPROM memory(0xBA);
void setup()
{
// Start UART
Serial.begin(9600);
// Start I2C
Wire.begin();
byte data[9];
// Read data[] starting from 21st byte
memory.readPage(21, data, 9);
}Example #2 #include <Wire.h>
#include <EEEPROM.h>
// Define new external EEPROM
EEEPROM memory(0xBA);
void setup()
{
// Start UART
Serial.begin(9600);
// Start I2C
Wire.begin();
byte *data;
// Read 9 bytes of data starting from 21st byte
memory.readPage(21, data, 9);
}void EEEPROM::writePage(unsigned int address, byte *data, int length)Write page to EEPROM. Page size should be max. 30 bytes. Example #1 #include <Wire.h>
#include <EEEPROM.h>
// Define new external EEPROM
EEEPROM memory(0xBA);
void setup()
{
// Start UART
Serial.begin(9600);
// Start I2C
Wire.begin();
byte data[] = {1, 1, 2, 3, 5, 8, 13, 21, 34};
// Write data[] starting from 21st byte
memory.writePage(21, data, 9);
}Example #2 #include <Wire.h>
#include <EEEPROM.h>
// Define new external EEPROM
EEEPROM memory(0xBA);
void setup()
{
// Start UART
Serial.begin(9600);
// Start I2C
Wire.begin();
byte data[] = {1, 1, 2, 3, 5, 8, 13, 21, 34};
// Write data[] starting from 21st byte
memory.writePage(21, data, sizeof(data));
}DownloadYou can download the EEEPROM library from our Libraries repository. |
