UDP packet Proccesing

I am having troubles processing a packet with the arduino. It will be recieving packets that contain, "red" or "green" or "yellow". How can i use those in an if statement? I have tried:

if(packetBuffer.equals("red") {
// do this
}

but it seems that the packetBuffer is in char. and i have also tried to test packetBuffer.charAt() but then it just wont do it... Any suggestions are much appreciated.

Look into "strcmp()" and post your code if you want more than a guess for help.

-br

This is my current code

void loop() {
  // if there's data available, read a packet
  int packetSize = Udp.parsePacket();
  if(packetSize)
  {
    Serial.print("Received packet of size ");
    Serial.println(packetSize);
    Serial.print("From ");
    IPAddress remote = Udp.remoteIP();
    for (int i =0; i < 4; i++)
    {
      Serial.print(remote[i], DEC);
      if (i < 3)
      {
        Serial.print(".");
      }
    }
    Serial.print(", port ");
    Serial.println(Udp.remotePort());

    // read the packet into packetBufffer
    Udp.read(packetBuffer,UDP_TX_PACKET_MAX_SIZE);
    Serial.println("Contents:");
    Serial.println(packetBuffer);
    if(packetBuffer.length() == 3) {
      analogWrite(ledr, 25);
      startr = millis() + 200;
    }
    if(rec.equals("r") {
      analogWrite(ledg, 25);
      startg = millis() + 200;
    }
    if(packetBuffer.equals("yel")) {
      analogWrite(ledy, 25);
      starty = millis() + 200;
    }
    if(startr <= millis()) {
      analogWrite(ledr, 0);
    }
    if(startg <= millis()) {
      analogWrite(ledg, 0);
    }
    if(starty <= millis()) {
      analogWrite(ledy, 0);
    }
  }
}

For best results, post all your code. Assuming however that you started out with the UDP example code, packetBuffer is an array of char so as Billroy suggests, strcmp will do what you need. Instead of:

if(packetBuffer.equals("yel"))

try

if(strcmp(packetBuffer,"yel")==0)

Thank You