I don't know much about serial communication in the arduino board. I am having some issues while using the substring() command and indexOf() command.
String command;
void setup(){
Serial.begin(38400);
Serial.println("Hi");
}
void loop(){
if(Serial.available()>0){
delay(5);
char c=Serial.read();
command+=c;
Serial.println(command.indexOf('l'));
if(command.substring(0)=="Update"){
Serial.println("Update...");
if(command.substring(7)=="color"){
Serial.println("Updated");
}
}
command="";
}
command="";
}
Practically what the user must do is he must type "Update color" and according to code some things are supposed to happen but they never are. Moreover, I have noticed that when I was suppose to get the the Index of 'l' the output are as follows:
Hi
-1
-1
-1
-1
-1
-1
-1
-1
-1
0
-1
-1
The things in the substring statements are not being carried out why?