Hello,
I am having issues getting a function that i made to work. I got the compiler to move get through the function without any errors but later in the code when the function is called i get "error: invalid conversion from 'int' to 'const char*'" and "error: initializing argument 1 of 'String::String(const char*)'" So I am wondering what I am doing to cause these errors and what I need to do to fix them.
String line;
char buf[200]= "Ax=-209 Ay=5 Az=1116 | Gx=7 Gy=0 Gz=7 | -31 233 -433 Headings 100.20";
void setup()
{
Serial.begin(57600);
}
int getVal(String x,String y)//input sting and what value thats wanted from the string
{
int s = x.indexOf(y,1); //find location in string
int e = x.indexOf(' ',s+4); //extract the info
String h = x.substring(s,e);
int t = h.toInt();
return t;
}
void parse(char buf[])
{
line = String (buf);
int xAxis = getVal(line,'Ax=');
int yAxis = getVal(line,'Ay=');
int ZAxis = getVal(line,'Az=');
int xGxis = getVal(line,'Gx=');
int YGxis = getVal(line,'Gy=');
int zGxis = getVal(line,'Gz=');
}
void loop()
{
}
I get the errors when the compiler reaches "xAxis" If I am completely on the wrong track with this let me know. I am still really new at this.