Pages: [1]   Go Down
Author Topic: comparing data coming from serial  (Read 128 times)
0 Members and 1 Guest are viewing this topic.
Lokombia
Offline Offline
Newbie
*
Karma: 0
Posts: 41
hackea negra hackea
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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:
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!
Logged

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 640
Posts: 50335
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Pages: [1]   Go Up
Jump to: