Hello Everyone,
I am new to programming and the Arduino environment. I am taking a class and an assignment is to create a sketch that will allow a person to read and write to EEPROM by typing read (EEPROM address) or write (EEPROM address, value).
I think i am on the right track and i am trying to code the right way (I think), but when I try to compile my code, I get an error on line 50 that says:
"exit status 1
invalid conversion from ‘int’ to ‘const char*’ [-fpermissive]"
I have tried to find code that would help covert, but everything I read doesn’t help me. I think most of it is over my head. If anyone has any suggestions on how i could do this, or even to do it better I would appreciate any constructive feedback you can give me. I have spent over 7 hours on this little bit of code, and I still can’t make it work.
Here is my sketch
/* This is a Sketch that will allow a peron to read and write values
- to the Arduino EEPROM. It takes two commands read and write.
- The read command takes 1 argument the EEPROM location and will
- return the value stored there. The write command takes 2 arguments
- (EEPROM loc, value) and will write the value to EEPROM location.
*/
#include <EEPROM.h>
#include <string.h>
#include <stdlib.h>
// start reading from the first byte (address 0) of the EEPROM
String instructions = “Type read(loc) or write(loc,value)in lowercase”;
String readlocout = "In EEPROM location ";
String readvalout = "This value is stored: ";
String writevalout = "You have put the value ";
String writelocout = " into EEPROM register ";
String getcommand;
String getaddr;
String getval;
int addr;
int value;
int readval;
void setup() {
// initialize serial and wait for port to open:
Serial.begin(9600);
while (!Serial) {
; // wait for serial port to connect. Needed for native USB port only
}
}
void loop() {
// put your main code here, to run repeatedly:
while (Serial.available() > 0) {
}
getcommand = Serial.readStringUntil(’ ');
Serial.read();
addr = Serial.parseInt();
Serial.read();
value = Serial.parseInt();
if(getcommand == ‘read’) readEEPROM(addr);
if(getcommand == ‘write’) writeEEPROM(addr, value);
else if (getcommand != ‘read’ && getcommand != ‘write’)
{
Serial.println(“That is not a valid command, use read or write”)
}
}
void readEEPROM(int addr) //Reads the value in the EEPROM location that is passed
{
Serial.println(“Reading from EEPROM”);
readval = EEPROM.read(addr);
Serial.print(readlocout);
Serial.print(addr);
Serial.print("\t");
Serial.print(readvalout);
Serial.println(readval);
delay(100);
}
void writeEEPROM(int addr, int value) //Writes the value to the EEPROM memory location
{
Serial.println(“Reading Serial In”);
EEPROM.write(addr, value);
delay(100);
Serial.print(writevalout);
Serial.print(value);
Serial.print("\t");
Serial.print(writelocout);
Serial.println(addr);
}