How does the Arduino Serial Monitor send the newline?

I am currently using the Arduino Serial Monitor to send a command string

 [s123][m123]

with the "newline" enabled at the bottom. If turned with no newline; it does not work. I would like to use a joystick for easier control; I am using java. However; simply adding "\n" to the string does not work. What does arduino use to enable a newline?

Thanks in advance!

The button at the bottom of the screen (normally says "No line ending") controls which line ending is sent after the data, when you hit the "send" button.

i am aware of that. but i am looking for a way to concatenate the newline in java. adding "\n" does not work. what can i use in java so arduino can understand newline?

'\n' is a newline. This is how you determine a newline has been sent.

char ch = Serial.read();
if(ch == '\n') Serial.println("newline");

Specifically, which setting have you selected? There are three choices. One appends nothing. One appends \r (or \n). The 3rd one appends both \r and \n, in some order. It isn't that difficult, unless you are lazy like me, to write a sketch that determines the correct order and value(s) appended.

what can i use in java so arduino can understand newline?

So your question has nothing to do with the "Serial Monitor" at all?
Arduino doesn't "understand" newline (unlike dealing with a unix or DOS command-line "read()", for example.) You can have it look for whatever your java app sends. (now: "What does a java app send when you specify "\n" in a string sent to the serial port?" is an interesting question...)

My guess is that the \n is being recognised by your javascript as a string terminator. Therefore stripping it back out when sending.

Since we don't have the benefit of your javascript code, it's just guesswork.

@joojieman, Can you tell us exactly what you are trying to do. I can't figure if you want the Java program to read or to send the data with (or without) the newline character.

...R

PS

KenF:
Since we don't have the benefit of your javascript code, it's just guesswork.

Java, NOT javascript - let's not get hopelessly confused.

Robin2:
PSJava, NOT javascript - let's not get hopelessly confused.

Hmm. I wonder though ... :wink:

KenF:
Hmm. I wonder though ... :wink:

Why - have I missed something (again) ?

...R