Serial.Println History

Hide minor edits - Show changes to markup

June 02, 2012, at 08:24 PM by David A. Mellis -
Changed lines 20-22 from:

byte
println() will return the number of bytes written, though reading that number is optional

to:

size_t (long): println() returns the number of bytes written, though reading that number is optional

January 30, 2012, at 05:12 PM by Scott Fitzgerald -
Changed lines 63-68 from:
to:
November 04, 2011, at 02:43 PM by Scott Fitzgerald -
Changed lines 20-21 from:

None

to:

byte
println() will return the number of bytes written, though reading that number is optional

September 24, 2011, at 01:33 AM by Tom Igoe -
Changed lines 24-25 from:

[@

to:
Changed lines 55-57 from:

}@]

to:
September 07, 2011, at 05:18 PM by Scott Fitzgerald - removed BYTE datatype
Deleted line 50:
  Serial.println(analogValue, BYTE); // print as a raw byte value
February 08, 2010, at 04:54 AM by David A. Mellis -
Changed lines 10-12 from:

Serial.print(val)
Serial.print(val, format)

to:

Serial.println(val)
Serial.println(val, format)

February 01, 2010, at 07:19 PM by David A. Mellis -
Changed lines 7-36 from:

Prints a data to the serial port, 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().

Serial.println(b) prints b as a decimal number in an ASCII string followed by a carriage return and a linefeed.

Serial.println(b, DEC) prints b as a decimal number in an ASCII string followed by a carriage return and a linefeed.

Serial.println(b, HEX) prints b as a hexadecimal number in an ASCII string followed by a carriage return and a linefeed.

Serial.println(b, OCT) prints b as an octal number in an ASCII string followed by a carriage return and a linefeed.

Serial.println(b, BIN) prints b as a binary number in an ASCII string followed by a carriage return and a linefeed.

Serial.print(b, BYTE) prints b as a single byte followed by a carriage return and a linefeed.

Serial.println(str) if str is a string or an array of chars, prints str an ASCII string.

Serial.println() just prints a carriage return and a linefeed.

Parameter

data types: integer types, including char, strings (char arrays) & floats

to:

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.print(val)
Serial.print(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)

February 01, 2010, at 05:30 PM by David A. Mellis -
Changed lines 35-38 from:

data types: integer types, including char, strings (char arrays) & floats
Printing of floats is supported with a precision of two places to the right of the decimal point.
This may change soon.

to:

data types: integer types, including char, strings (char arrays) & floats

February 01, 2010, at 05:30 PM by David A. Mellis -
Changed lines 1-2 from:

Serial.println(data)

to:

Serial

println()

Changed lines 7-8 from:

Prints a data to the serial port, 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():

to:

Prints a data to the serial port, 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().

Deleted lines 78-80:

Programming Tip / Known Issues

see Serial.print

Changed lines 80-88 from:
to:
July 24, 2009, at 01:20 AM by Paul Badger -
Changed lines 31-37 from:

Parameters

b: the byte to print, or

str: the string to print

to:

Parameter

data types: integer types, including char, strings (char arrays) & floats
Printing of floats is supported with a precision of two places to the right of the decimal point.
This may change soon.

July 24, 2009, at 01:17 AM by Paul Badger -
November 04, 2008, at 07:31 AM by Massimo Banzi -
Changed line 67 from:
  Serial.print(analogValue, DEC);  // print as an ASCII-encoded decimal
to:
  Serial.println(analogValue, DEC);  // print as an ASCII-encoded decimal
July 19, 2007, at 05:29 AM by Paul Badger -
Added lines 76-80:

Programming Tip / Known Issues

see Serial.print

Added line 90:
May 31, 2007, at 04:38 PM by David A. Mellis - we don't care about the old serial library any more (it should be removed soon)
Changed lines 5-6 from:

Prints a data to the serial port, followed by a carriage return character(ASCII 13, or '\r') and a newline character (ASCII 10, or '\n'). (Note that the printNewline() function from the old serial library sent only a newline.) This command takes the same forms as Serial.print():

to:

Prints a data to the serial port, 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():

May 30, 2007, at 06:25 PM by Paul Badger -
Changed lines 75-78 from:

}

@]

to:

}@]

May 30, 2007, at 06:25 PM by Paul Badger -
Deleted lines 76-77:
Added line 80:
June 08, 2006, at 06:07 PM by David A. Mellis - old printNewline() only send newline
Changed lines 5-6 from:

Prints a data to the serial port, 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():

to:

Prints a data to the serial port, followed by a carriage return character(ASCII 13, or '\r') and a newline character (ASCII 10, or '\n'). (Note that the printNewline() function from the old serial library sent only a newline.) This command takes the same forms as Serial.print():

March 27, 2006, at 08:58 PM by Tom Igoe -
Changed lines 5-6 from:

Prints a data to the serial port, 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():

to:

Prints a data to the serial port, 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():

Changed lines 82-85 from:
to:
March 27, 2006, at 08:55 PM by Tom Igoe -
Added line 21:
March 27, 2006, at 08:55 PM by Tom Igoe -
Changed lines 21-23 from:
to:

Serial.print(b, BYTE) prints b as a single byte followed by a carriage return and a linefeed.

March 27, 2006, at 08:51 PM by Tom Igoe -
Changed lines 64-65 from:
   Serial.print(analogValue, DEC);  // print as an ASCII-encoded decimal
   Serial.println(analogValue, HEX);  // print as an ASCII-encoded hexadecimal
to:
  Serial.print(analogValue, DEC);  // print as an ASCII-encoded decimal
  Serial.println(analogValue, HEX);  // print as an ASCII-encoded hexadecimal
March 27, 2006, at 08:51 PM by Tom Igoe -
Changed lines 1-2 from:

Serial.print(data)

to:

Serial.println(data)

March 27, 2006, at 08:50 PM by Tom Igoe -
Changed line 7 from:

Serial.printlnln(b)

to:

Serial.println(b)

Changed lines 79-81 from:

to:
March 27, 2006, at 08:50 PM by Tom Igoe -
Added lines 1-82:

Serial.print(data)

Description

Prints a data to the serial port, 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():

Serial.printlnln(b) prints b as a decimal number in an ASCII string followed by a carriage return and a linefeed.

Serial.println(b, DEC) prints b as a decimal number in an ASCII string followed by a carriage return and a linefeed.

Serial.println(b, HEX) prints b as a hexadecimal number in an ASCII string followed by a carriage return and a linefeed.

Serial.println(b, OCT) prints b as an octal number in an ASCII string followed by a carriage return and a linefeed.

Serial.println(b, BIN) prints b as a binary number in an ASCII string followed by a carriage return and a linefeed.

Serial.println(str) if str is a string or an array of chars, prints str an ASCII string.

Serial.println() just prints a carriage return and a linefeed.

Parameters

b: the byte to print, or

str: the string to print

Returns

None

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.print(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
  Serial.println(analogValue, BYTE); // print as a raw byte value

  // delay 10 milliseconds before the next reading:
  delay(10);
}




See also

Reference Home

Share