Getting problem with if case

Hello everyone ,
Getting problem with little code. Even if the 'mdp' is correct from the 'Serial.read' the condition doesn't execute. someboby could help me please
String incomingRead;
String mdp = "ABDC1234";

void readCode(){
if(Serial.available() > 0){
Serial.println("yo");
incomingRead = Serial.readString();
Serial.println(incomingRead);
if(incomingRead == mdp){
Serial.println("casier 1 ouvert");
Serial.println(mdp);
Serial.println(incomingRead);
}
else{
Serial.println("echouer");
Serial.println(incomingRead);
Serial.println(mdp);
}
}
}

You need to post a complete program.

While it's probably not directly related to your current problem it is not a good idea to use the String (capital S) class on an Arduino as it can cause memory corruption in the small memory on an Arduino. This can happen after the program has been running perfectly for some time. Just use cstrings - char arrays terminated with '\0' (NULL).

When using Cstrings you must use strcmp() to compare values rather than ==

Have a look at the examples in Serial Input Basics - simple reliable ways to receive data. There is also a parse example to illustrate how to extract numbers from the received text.

...R