Hi,
I think im missing something really simple and its driving me nuts.
Im using the example for the R/W to the I2C EEPROM found here:
void writeEEPROM(int deviceaddress, unsigned int eeaddress, byte data )
{
Wire.beginTransmission(deviceaddress);
Wire.write((int)(eeaddress >> 8)); // MSB
Wire.write((int)(eeaddress & 0xFF)); // LSB
Wire.write(data);
Wire.endTransmission();
delay(5);
}
byte readEEPROM(int deviceaddress, unsigned int eeaddress )
{
byte rdata = 0xFF;
Wire.beginTransmission(deviceaddress);
Wire.write((int)(eeaddress >> 8)); // MSB
Wire.write((int)(eeaddress & 0xFF)); // LSB
Wire.endTransmission();
Wire.requestFrom(deviceaddress,1);
if (Wire.available()) rdata = Wire.read();
return rdata;
}
I am writing to and reading from the EEPROM just fine when i send one data value:
writeEEPROM(disk1, 1, 123);
Serial.println(readEEPROM(disk1, 1), DEC);
Serial.println("");
But when i try to send a different data value to store in a different address, all im getting in the Serial Monitor is "123" then "200", instead of "123" then "456".
writeEEPROM(disk1, 1, 123);
Serial.println(readEEPROM(disk1, 1), DEC);
Serial.println("");
writeEEPROM(disk1, 2, 456);
Serial.println(readEEPROM(disk1, 2), DEC);
Serial.println("");
Any pointers? I know its got to be something simple.