Weblessons.org
Reference Language| extended() | Libraries | Comparison | Board
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'). This command takes the same forms as
Serial.print().
Syntax
Serial.println(val)
Serial.println(val, format)
Parameters
val: the value to print - any data type
format: specifies the number base (for integral data types) or number of decimal places (for floating point types)
Returns
size_t (long): println() returns the number of bytes written, though reading that number is optional
Example:
/*
Analog input
reads an Analog input on Analog in 0, prints the value out.
created 24 March 2006
by Tom Igoe
*/
int AnalogValue =
0
; // variable to hold the Analog value
void
setup
(
)
{
// open the serial port at 9600 bps:
Serial.begin
(
9600
)
;
}
void
loop
(
)
{
// read the Analog input on pin 0:
AnalogValue =
AnalogRead
(
0
)
;
// print it out in many formats:
Serial.println
(AnalogValue)
; // print as an ASCII-encoded decimal
Serial.println
(AnalogValue,
DEC
)
; // print as an ASCII-encoded decimal
Serial.println
(AnalogValue,
HEX
)
; // print as an ASCII-encoded hexadecimal
Serial.println
(AnalogValue,
OCT
)
; // print as an ASCII-encoded octal
Serial.println
(AnalogValue,
BIN
)
; // print as an ASCII-encoded binary
// delay 10 milliseconds before the next reading:
delay
(
10
)
;
}
See also
Reference Home
The text of the Arduino reference is licensed under a Creative Commons Attribution-ShareAlike 3.0 License. Code samples in the reference are released into the public domain.