EEPROM reading and saving via Serial Monitor

thanks chuck for your help :smiley:

actually i want to discuss something with you, i already placed EEPROM.get and EEPROM.put functions, thanks for the enriching information.

i also want to tell you that i think the problem is with the code in the void loop because i never get the message "COMMAND NOT RECOGNIZED" for any order i put with the Serial monitor. i tried to expose this error, and have put a println order to print the command string -i'm saving to- after the if new line.

and guess what, it didn't print anything as i thought :smiley:

happy that i have been able to expose a bug, not so happy because i can't fix it :smiley:
and here i will try attaching my 'modified' code.

would like to hear what you think.

i also downloaded the string.ino file and didn't understand it :smiley: , i see similar stuff when using atmel studio and wrongly press debugg. i'm a bit of beginner you see. and failed to make my code appear as you did. this line is my reply edit.

void setup()
{
Serial.begin(9600);
Serial.println("This code allows you to read and write from the EEPROM memory");
/* add setup code here */

}
#include <EEPROM.h>
String command;
void loop()
{
if (Serial.available())
{
char c=Serial.read();
if (c=='\n')
{
Serial.print(command);
parseCommand(command);
command="";
}
else
command+= c;
}
}

void parseCommand (String com)
{
String part1;
String part2;
String part3;
part1 = com.substring(0, com.indexOf(" "));
part2 = com.substring(com.indexOf(" ")+1);
if(part1.equalsIgnoreCase("read"))
{
int addressRead = part2.toInt();
int valueRead;
EEPROM.get(addressRead,valueRead);
Serial.print("\n");
Serial.print("ADDRESS:");
Serial.print(addressRead, DEC);
Serial.print("\t");
Serial.print("VALUE:");
Serial.print(valueRead, DEC);
}
else if(part1.equalsIgnoreCase("write"))
{
part2 = com.substring(com.indexOf(" ")+1);
part3 = part2.substring(part2.indexOf(" ")+1);
String address=part2.substring(0,part2.indexOf(" "));
int addressWrite = address.toInt();
int valueWrite = part3.toInt();

EEPROM.put(addressWrite, valueWrite);
Serial.print("saved");
Serial.print(valueWrite, DEC);
Serial.print("to");
Serial.print(addressWrite, DEC);
}
else
{
Serial.println("COMMAND NOT RECOGNIZED");
}
}

hey.ino (1.35 KB)