Arduino Forum upgrade scheduled for Monday, October 20th, 11am-4pm (CEST). Sorry for the inconvenience!
Pages: [1]   Go Down
Author Topic: if vergleich funktioniert nicht  (Read 470 times)
0 Members and 1 Guest are viewing this topic.
Thuringia, Germany
Offline Offline
Newbie
*
Karma: 0
Posts: 46
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Hallo Community,

ich habe in meinem Code einen if-Vergleich, der jedoch nicht funktioniert.
Woran kann das liegen? Was mache ich falsch?

Code:
void writeOutput(char OutString[])
{
  /*set Output on Rainbowduino*/
  char *p = OutString;
  char *str;
 
  while ((str = strtok_r(p, "-", &p)) != NULL)
  {
    lcd.clear();
    delay(500);
    Serial.println(str);
    if (str == "PF")
    {
      lcd.write(2);
      lcd.write(2);
    }
    else if (str == "GG")
    {
      lcd.write(1);
      lcd.write(1);
    }
    else if(str=="90")
    {
      lcd.write(3);
      lcd.write(3);
    }
    else
    {
      lcd.print(str);
    }
   
    /*delay(2000);*/
   
    /*Write str to Rainbowduino*/
    delay(500);
  }
}

Viele Grüße
Basti
Logged

Germany
Offline Offline
Faraday Member
**
Karma: 63
Posts: 3133
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

if (str == "GG")

vergleicht zwei Pointer, die nie gleich sein werden...

du suchst nach strcmp
Logged

Thuringia, Germany
Offline Offline
Newbie
*
Karma: 0
Posts: 46
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

OH, super, danke
Logged

Pages: [1]   Go Up
Arduino Forum upgrade scheduled for Monday, October 20th, 11am-4pm (CEST). Sorry for the inconvenience!
Jump to: