Hi guys im trying to compare the Content of SMS.
But i dont know how i should do this.
I know that in the example they use:
" while( (c = sms.read()) ! = -1)
{
Serialprintln ((char)c) ;
}
"
but i should compare the SMS and watch if it matches my keyword for Example "ON"
and i dont need to write it some where like in the example
and then do stuff but I just dont get it how i should code this...
pls help
Look at this tutorial: Serial Input Basics - updated to learn how to read in a string and then act upon it. The tutorial is designed for Serial input, but will work for SMS input just as well.
i know how to read in a string so u mean i could do something like:
" for( i = 0; i<7; i ++)
{
Sms_String [i] = sms.read() ;
}
if "Sms_String == "GO ON""
and here we have the same problem i cant compare with a string cause idk what to put in the braces [?] to use the whole string i dont need to use the braces right just the name so it doesnt have a Index?
come on guys i have no clue how to solve this. And its a very important project to me.
strcmp just compares characters but sms.read() gives a int back so this cant work.
String SmS [7];
String Command [7];
Command[1] = "O";
Command[2] = "N";
int i = 0;
for(;i<7;i++)
{
SmS[i] = sms.read();
}
if ( (strcmp(SmS,Command)))
{
Serial.println("\nOutput now ON");
}
ive used this now but there is a ERROR saying: "cannot convert 'arduino::String*' to 'const char*' for argument '1' to 'int strcmp(const char*, const char*)'"
and btw could you tell me the diffrence between strcmp() and strncmp()? thx