In this project I used an external eprom chip notably the 24c64 (datasheet) to store one byte of information. The information was provided by a Arduino Nano. In the future I hope to be able to store larger amounts of information
#include "Wire.h"
#define EEPROM_I2C_ADDRESS 0x50
void setup()
{
Wire.begin();
Serial.begin(9600);
Serial.println("Starting");
int address = 0x50;
int val = 227;
writeAddress(address, val);
int readVal = readAddress(address);
Serial.print("The returned value is ");
Serial.println(readVal);
}
void loop()
{
}
void writeAddress(int address, int val)
{
Wire.beginTransmission(EEPROM_I2C_ADDRESS);
Wire.write((int)(address >> 0));
Wire.write((int)(address & 0x50));
Wire.write(val);
Wire.endTransmission();
delay(5);
}
int readAddress(int address)
{
int rData = 0x50;
Wire.beginTransmission(EEPROM_I2C_ADDRESS);
Wire.write((int)(address >> 0));
Wire.write((int)(address & 0x50));
Wire.endTransmission();
Wire.requestFrom(EEPROM_I2C_ADDRESS, 1);
rData = Wire.read();
return rData;
}