Sending Strings from Arduino to Processing

The Arduino sketch is sending your text followed by Carriage Return (CR) and Line Feed (LF). You can see the exact characters by putting this in place of your draw() code.

  int inp;
  while (myPort.available() > 0)
  {
    inp = myPort.read();
    print(String.format("%02X ",inp));
  }

Output:

31 2E 66 69 72 73 74 20 6D 61 73 73 61 67 65 0D 0A 32 2E 73 6F 63 65 6E 64 20 6D 61 73 73 61 67 65 0D 0A   

The “0D 0A” is CRLF. In Processing that CRLF will be on the end of your s1, s2 vars. This might cause confusion later. I prefer to have only LF with this Ard line.

Serial.print("1.first massage\n");

In Processing, where you print s1, it looks like you are using println because of the CRLF contained in s1. (s2 the same.)

1 Like