sark86:
void loop ()
{
sensorValue = analogRead (analogInPin);
writeEEPROM (address, (byte *) &sensorValue, sizeof sensorValue);
byte test2 [2]
readEEPROM (address, test2, sizeof test2);
Serial.println ((char *) test2);
addr += sizeof sensorValue;
Serial.print("analog pin: ");Serial.print (sensorValue, DEC);Serial.print('\n',BYTE); //debug
Serial.print("address: ");Serial.print (address, DEC);Serial.print('\n',BYTE); //debug
} // end of loop
I'm confused on how to read the int after it has been written. I had the test2 byte in there just so I could try to read something, but all I got out was garbage.
When writing we passed the address of sensorValue (ie. &sensorValue) so you have to do the same thing when reading back. That is:
int test;
readEEPROM (address, &test, sizeof test);
That reads back into the 2-byte integer in the same way we wrote the data tout.