Hi, I know i dont have to parse the data in this case, but when i want to extract more data from Serial.read string, i must. Now when I want to print the data it says
exit status 1
no matching function for call to 'println(int (&)(String))'
when I use it like this
String rread = "R0";
void setup(){
Serial.begin(9600);
}
int parseData(String rread){
rread.remove(0,1);
return rread.toInt();
}
void loop(){
Serial.println(parseData);
}
It doesnt even work when i put it into switch.
String rread = "R0";
void setup(){
Serial.begin(9600);
}
int parseData(String rread){
rread.remove(0,1);
return rread.toInt();
}
void loop(){
switch(parseData){
case 0:
digitalWrite(2,0)
break;
case 1:
digitalWrite(2,1)
break;
}
}
This is the error message:
exit status 1
switch quantity not an integer
Also it doesnt work when use it in if statement
String rread = "R0";
void setup(){
Serial.begin(9600);
}
int parseData(String rread){
rread.remove(0,1);
return rread.toInt();
}
void loop(){
if (parseData = 1){
digitalWrite(2,1);
} else {
digitalWrite(2,0);
}
}
This is the error message:
exit status 1
assignment of function 'int parseData(String)'
I also tried changing the "1" to a string in the if statement
String rread = "R0";
void setup(){
Serial.begin(9600);
}
int parseData(String rread){
rread.remove(0,1);
return rread.toInt();
}
void loop(){
if (parseData = "1"){
digitalWrite(2,1);
} else {
digitalWrite(2,0);
}
}
But with no success
exit status 1
assignment of function 'int parseData(String)'
Thank you for answers.