#include <EEPROM.h>
int rgb_code[4];
String colour;
void setup()
{
Serial.begin(115200);
delay(5000);
Serial.println("");
Serial.println("Writing EEPROM");
EEPROM.write(0,0);
EEPROM.write(1,0);
EEPROM.write(2,128);
EEPROM.commit();
Serial.println("Waiting 10 seconds...");
delay(10000);
Serial.println("Reading EEPROM");
Serial.println("");
rgb_code[1] = int(EEPROM.read(0));
rgb_code[2] = int(EEPROM.read(1));
rgb_code[3] = int(EEPROM.read(2));
colour = "RGB - ";
colour += rgb_code[1];
colour += ":";
colour += rgb_code[2];
colour += ":";
colour += rgb_code[3];
Serial.println(colour);
}
void loop()
{
}
The code always print 0:0:0 which indicates that the EEPROM write has not been carried out, in addition infoo online indicates that the EEPROM should return 255 if no value has been previously written. Am I making a simple error in my code? Is the .commit required after the write, adding it makes no difference.
nscripta