Coding Help

Add some extra Serial.print statements to see what your code is doing. Examining the intermediate results should make it clear why the code is failing.

      char inChar = Serial.read();
      Serial.print("inChar ");
      Serial.print((int)inChar, DEC);
      Serial.print(' ');
      Serial.println(inChar);
      txtMsg += inChar; // add any incoming characters to the String:
      Serial.print("txtMsg "); Serial.println(txtMsg);

HINT 1: In the serial console window, set it to "No line ending". If do you do not, your program will receive invisible characters such as line feed or carriage return or both. This will not fix the problem but it reduces the complexity.

HINT 2: The for loop executes only 1 time so it can be removed. But this will not fix the problem.