Serial.println()
Description
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.
Syntax
Serial.println(val)
Serial.println(val, format)
Parameter Values
- 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:
- The base (format) to be printed for integral data types (byte, char, int, long, short, unsigned char, unsigned int, unsigned long, word). The permitted values are:
- BIN: binary, or base 2
- OCT: octal, or base 8
- DEC: decimal, or base 10
- HEX: hexadecimal, or base 16
Return Values
- println() returns the number of bytes written, though reading that number is optional. Data type: size_t.
Example Code
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)
See Also
- Language : Arduino - Serial
- Language : Serial.available()
- Language : Serial.availableForWrite()
- Language : Serial.begin()
- Language : Serial.end()
- Language : Serial.find()
- Language : Serial.findUntil()
- Language : Serial.flush()
- Language : Serial.getTimeout()
- Language : if(Serial)
- Language : Serial.parseFloat()
- Language : Serial.parseInt()
- Language : Serial.peek()
- Language : Serial.print()
- Language : Serial.read()
- Language : Serial.readBytes()
- Language : Serial.readBytesUntil()
- Language : Serial.readString()
- Language : Serial.readStringUntil()
- Language : serialEvent()
- Language : Serial.setTimeout()
- Language : Serial.write()
※ ARDUINO BUY RECOMMENDATION
Arduino UNO R3 | |
Arduino Starter Kit |
Additionally, some links direct to products from our own brand, DIYables.