I am trying to compare two string but each time i am getting awkward results. When i use Equals() function i always get the wrong answer and never satisfy the IF statement. When i use compareTo() function i always get the right answer (which is btw not correct) but it always just satisfy the IF statement.
String input;
String Answer = "cat";
void setup()
{
Serial.begin(19200);
}
void loop()
{
while (Serial.available() == 0)
{
Serial.readStringUntil('\n');
if (input.equals(Answer))
{
Serial.println(input + ", Correct");
}
else
{
Serial.println(input + ", wrong");
}
}
}
Above is the code i am using to learn the string Comparison.