Prints data to the serial port as human-readable ASCII text followed by a carriage return character (ASCII 13, or '\r') and a newline character (ASCII 10, or '\n').
Serial.println() is the same as Serial.print(), except for one thing: Serial.println() prints '\r' and '\n' character at the end while Serial.print() does not.
- Serial: serial port object. See the list of available serial ports for each board on the Serial main page.
- val: the value to print. Allowed data types: any data type.
- format: (optional) specifies:
- BIN: binary, or base 2
- OCT: octal, or base 8
- DEC: decimal, or base 10
- HEX: hexadecimal, or base 16
- println() returns the number of bytes written, though reading that number is optional. Data type: size_t.
The result on Serial Monitor:
※ NOTES AND WARNINGS:
- For information on the asyncronicity of Serial.println(), see the Notes and Warnings section of the Serial.write() reference page.
- Serial functions are not only used for the communication between an Arduino board and Serial Monitor of Arduino IDE but also used for the communication between:
- An Arduino board and other Arduino board
- An Arduino board and other sensors/devices
- An Arduino board and computer (any Serial software on computer)