Pages: [1]   Go Down
Author Topic: Help with EEPROM.write()  (Read 422 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
Full Member
***
Karma: 1
Posts: 137
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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:
#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
Logged

Global Moderator
Dallas
Offline Offline
Shannon Member
*****
Karma: 207
Posts: 12911
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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

0
Offline Offline
Full Member
***
Karma: 1
Posts: 137
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Pages: [1]   Go Up
Jump to: