Go Down

Topic: Help with EEPROM.write() (Read 464 times) previous topic - next topic

phinsil6

Hi, I am simply trying to write a byte of data to the EEPROM and then read it to the serial port as shown with the following code:
Code: [Select]
#include <EEPROM.h>

byte data[1] = {192};
int a = 1;
int value;

void setup()
{
 EEPROM.write(a, data[1]);
 Serial.begin(9600);
}

void loop()
{
 value = EEPROM.read(a);
 Serial.print(a);
 Serial.print("\t");
 Serial.print(value);
 Serial.println();
}


But all the serial window shows is "1       1".  Meaning that the value stored at EEPROM Address 1 is 1.  But the value written should 192 right?  Am I missing something really simple here?

thanks

Coding Badly

Code: [Select]
 EEPROM.write(a, data[[glow]0[/glow]]);
...C indexes are zero based.

phinsil6

wow I can't believe I missed that.  its a first time of programming for me
thanks a lot

Go Up