Serial event: Input string not being picked up

Hi everyone, I would like to type/send a command to arduino, for it to correspondingly run a function. The code I have written is shown below, I am using the serial event structure. Except when I type a command for example "Move", arduino reads this in, but does not run the function I want it to run. Does any one know why?

Many thanks,
Sam

void loop()
{
if(stringComplete)
{
Serial.println(inputString);
if(inputString=="Move")
{
moveUntilPos();
}
if(inputString=="Scan")
{
scan();
}
}
}

You have not posted your complete program so I have no idea where the problem might be.

Have a look at the examples in Serial Input Basics - simple reliable ways to receive data. There is also a parse example.

It is not a good idea to use the String (capital S) class on an Arduino as it can cause memory corruption in the small memory on an Arduino. Just use cstrings - char arrays terminated with 0.

...R

Thank you robin2, I have actually managed to fix it. i think arduino prefers if(inputString.equals("move")) to the version I put in.

I am glad that you fixed it because without seeing your complete program it is impossible to provide meaningful help.

== and .equal does the same

But "Move" and "move" are not the same :wink: