Hey, I'm having an issue with reading values from the EEPROM chip that I set up in I2C. It's meant to be getting readings from an accelerometer that's hooked up (the accelerometer works fine).
I'm sure that the values are getting stored correctly, since the oscilloscope is showing data transfer when I connect it up, but when I try to read the values back in decimal they all always come back as 255. Is there something wrong with the Wire.read section of my code, which would cause 'value' to always show as 255?
Sorry about how bad the coding may seem, but any help would be greatly appreciated. Thanks.
The full code that I used should be shown below.
#include <SPI.h>
#include <ADXL362.h>
#include <Wire.h>
#define memory 0x50 //address of the eeprom chip
ADXL362 xl;
byte address = 0;
byte XValue, YValue, ZValue;
byte value;
byte counter1;
#define led 13
void setup(){
pinMode(13,OUTPUT);
Serial.begin(9600);
Wire.begin();
xl.begin(10); // Setup SPI protocol, issue device soft reset
xl.beginMeasure(); // Switch ADXL362 to measure mode
Serial.println("Start Demo: Simple Read");
Wire.beginTransmission(address);
for (counter1 = 0; counter1 < 30; counter1++){
xl.readXYZ8Data(XValue, YValue, ZValue);
Serial.print("XVALUE=");
Serial.print(XValue);
Serial.print("\tYVALUE=");
Serial.print(YValue);
Serial.print("\tZVALUE=");
Serial.println(ZValue);
Wire.write((byte)(address, XValue));
address++;
Wire.write((byte)(address, YValue));
address++;
Wire.write((byte)(address, ZValue));
address = address + 1;
delay(100);
}
Wire.endTransmission();
Serial.println("Finished Writing");
digitalWrite(13,HIGH);
delay(5000);
Wire.beginTransmission(address);
for (counter1 = 0; counter1 < 90; counter1++){
byte value = Wire.read();
Serial.print(counter1);
Serial.print("\t");
Serial.println(value, DEC);
delay(10);
}
Wire.endTransmission();
while(1){
}
}