Go Down

Topic: comparing data coming from serial (Read 153 times) previous topic - next topic

mako

I have seen this subject in some threads, but cant make it work yet to compare

I send a char* from my serial message, I can log it ok ,but comparison with an  specific word is not working

Code: [Select]
void entro(char* valu)
{
 Serial.println("tomad:");
Serial.println(valu);

 String mystr = String(valu);
 Serial.println("tomad tu strg::" + mystr);

 String ss = String("ss9");
 
 if (mystr == ss)
 {
   Serial.println("si docto!");
 } //not working
 
  if (strcmp(valu, "ss9")  == 0)  // test to see if the two strings are equal
 {
  Serial.print("tkt");
 }  //not working
}


So what is missing? how to compare the char* with a string?

thanks!

PaulS

Quote
how to compare the char* with a string?

How do you know that the code is not working? How do you expect us to know? You don't say what is in valu, nor do you show how the function is called. Nor have you presented any proof, like serial output.

Go Up