I want to print error in case the word that i entered in the serial monitor is different from 9 of lenght but it prints error all the time because the program itself doenst know when i´m entering a word.
// C++ code
//
void setup()
{
Serial.begin(9600);
Serial.println("Checksum");
}
void loop()
{
String s = Serial.readString();
if (s.length() == 9)
{
for (int i = 0; i < 9; i++)
{
Serial.print(s[i]);
Serial.println(" ");
Serial.print((byte)s[i], HEX);
Serial.println(" ");
Serial.println(" ");
Serial.println();
}
Serial.println("Ok");
}
if (s.length() != 9)
{
//Serial.println("Error"); //here is the error
}
}