Hello,
I need to send a couple of characters to my device to get it going. I'm able to get the characters sent but I'm having trouble getting the 'carriage return' to be sent.
The execution of the above codes put o and c on the same line one after another, and the presentation is like: oc. Then --
What does Serial.write('\r') do after the Serial.write('o') command. My understanding is this: the \r (CR = 0x0D) brings the cursor at the beginning of the line; if so, the character c should be written over o; but, this is not.
If we look at the case of dot printer/type writer, we observe that the print-head reaches to the end and then it returns to the beginning position; this is known as Carriage Return. Is this carriage return is similar to the carriage return (CR) represented by 0x0D? After that, the paper goes up one line (auto/manual); this is known as Line Feed. Is this line feed is similar to the line feed (LF) represented by the code 0x0A? Practically, we observe that: \n, ln, and 0x0A do the same job; but, the role of \r (0x0D) is not understood.
Would appreciate to have some better views on the role of:
What does Serial.write('\r') do after the Serial.write('o') command.
That depends on how the system receiving the data is written. For instance, the Serial monitor does not return the print position to the start of the line on receipt of a carriage return. It is ignored.
UKHeliBob:
That depends on how the system receiving the data is written. For instance, the Serial monitor does not return the print position to the start of the line on receipt of a carriage return. It is ignored.
Your codes are executed; yes, the CR (\r) is ignored by the Serial Monitor of IDE. However, it (\r = CR) is not ignored by the LCD Monitor. It prints a non-friendly character between a and b while printing the message char s[4] = {'a', '\r', 'b', '\0'};. This indicates that the Reception Program of the Serial Monitor has been designed to filter out the CR (\r) character.