Uno R3 doesn't take string?

int i=1;
String pi;
void setup() {
Serial.begin(19200);
}

void loop() {
while (Serial.available()==0) {

}
pi= Serial.readString();
Serial.println(pi);
if (pi == “fdaaa”) {Serial.println(“while is good”);
}
}

Above is my code. I type in fdaaa in monitor. But it doesn’t print while is good.
When I use string, the while function never worked. What’s wrong? Please help me out. Thanks!

The problem is likely the line ending setting you have selected in Serial Monitor. If you set it to "No line ending", the code will work as you are expecting. If you have it set to automatically add a line ending via any of the other options then pi will not equal "fdaa" and so "while is good" will not be printed.

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

Have a look at the examples in Serial Input Basics - simple reliable ways to receive data.

...R