Arduino new line
A simple but important topic!
In Arduino, when you want to print a new line, you can use the println()
function. This function prints the output followed by a newline character (\n
).
Here's an example:
Serial.println("Hello, world!");
This will print "Hello, world!" followed by a newline character, so the output will be:
Hello, world!
If you want to print a new line without printing a newline character, you can use the print()
function instead:
Serial.print("Hello, world!");
Serial.println();
This will print "Hello, world!" and then print a newline character, so the output will be:
Hello, world!
Note that println()
is a shortcut for print()
followed by println()
, so you can use either one depending on your needs.
Also, if you're using a serial monitor like the Arduino Serial Monitor, you can use the "Newline" option to automatically add a newline character at the end of each line.