Where does /n char come from

This is probably very simple because I see it in a lot of Processing code. Say we are reading a sensor attached to an analog input on the Arduino board and we want to graph the output with a Processing program. I see these lines a lot (from the Processing website);

// Example by Tom Igoe

import processing.serial.*; . . . void setup() { . . . myPort = new Serial(this, Serial.list()[0], 9600); myPort.bufferUntil('/n'); } . . . Where does the /n char (ASCII 10 or 13, can't remember which) come from? If it's from the sensor and the sensor never outputs that number, what then? Or is /n added automatically when the buffer is filled? I've really confused myself! Thanks.

I don't know what is producing the data, but if it's a n Arduino which uses Serial.println, it comes from from that function. Otherwise, adding a line end (either \n or \r\n like println does) is a very common thing as it ends the line. Look at your serial data with your serial monitor. If the data is one by line, the sensor sends it that way.

If that's not the case, processing is very weird.


That has to be it. The code for the Arduino side has this line of code:


Thank you very much!!!!!

(The data was being produced from turning a potentiometer)

Serial.print will ‘fix’ this.