Serial.Print History

Hide minor edits - Show changes to output

June 02, 2012, at 08:25 PM by David A. Mellis -
Changed lines 39-41 from:
byte\\
print() will return the number of bytes written, though reading that number is optional
to:
size_t (long): print() returns the number of bytes written, though reading that number is optional
January 30, 2012, at 05:13 PM by Scott Fitzgerald -
Changed lines 99-100 from:
* [[(Reference.)Serial.write]]()
* [[(Reference.)Serial.println]]()
to:
(:include Reference/SerialSeeAlsoIncludes:)\\
November 04, 2011, at 02:43 PM by Scott Fitzgerald -
Changed lines 39-40 from:
None
to:
byte\\
print() will return the number of bytes written, though reading that number is optional
November 01, 2011, at 09:36 PM by Scott Fitzgerald -
Changed lines 93-95 from:
!!!!Programming Tips / Known Issues
The last character to be printed is transmitted over the serial port after Serial.print() has returned.
to:
!!!!Programming Tips
As of version 1.0, serial transmission is asynchronous; Serial.print() will return before any characters are transmitted.
October 31, 2011, at 02:39 PM by Tom Igoe -
Changed lines 43-44 from:
[@/*
to:
(:source lang=arduino tabwidth=4 :)
/*
Changed lines 90-91 from:
}@]
to:
}
(:sourceend:)
October 31, 2011, at 01:41 AM by Scott Fitzgerald -
Changed lines 98-100 from:


to:
*[[Tutorial/Memory | Memory]]

October 31, 2011, at 01:39 AM by Scott Fitzgerald - added flash memory based string information
Added lines 22-24:
You can pass flash-memory based strings to Serial.print() by wrapping them with F(). For example :
*Serial.print(F(“Hello World”))
September 07, 2011, at 05:20 PM by Scott Fitzgerald -
Changed lines 22-24 from:


to:
To send a single byte, use [[(Reference.)Serial.write]]().

September 07, 2011, at 05:17 PM by Scott Fitzgerald - removed reference to serial.print(byte, BYTE)
Deleted line 9:
* Serial.print(byte(78)) gives "N" (whose ASCII value is 78)
Changed lines 13-14 from:
An optional second parameter specifies the base (format) to use; permitted values are BYTE, BIN (binary, or base 2), OCT (octal, or base 8), DEC (decimal, or base 10), HEX (hexadecimal, or base 16). For floating point numbers, this parameter specifies the number of decimal places to use. For example:
* Serial.print(78, BYTE) gives "N"
to:
An optional second parameter specifies the base (format) to use; permitted values are BIN (binary, or base 2), OCT (octal, or base 8), DEC (decimal, or base 10), HEX (hexadecimal, or base 16). For floating point numbers, this parameter specifies the number of decimal places to use. For example:
Added lines 23-24:

Deleted lines 65-66:
Serial.println("BYTE");
Changed lines 81-84 from:
Serial.print(x, BIN); // print as an ASCII-encoded binary
Serial.print("\t"); // prints a tab

Serial.println(x, BYTE); // prints as a raw byte value,
to:
Serial.println(x, BIN); // print as an ASCII-encoded binary
February 01, 2010, at 07:17 PM by David A. Mellis -
Changed lines 7-8 from:
Prints data to the serial port.
to:
Prints data to the serial port as human-readable ASCII text. This command can take many forms. Numbers are printed using an ASCII character for each digit. Floats are similarly printed as ASCII digits, defaulting to two decimal places. Bytes are sent as a single character. Characters and strings are sent as is. For example:
* Serial.print(78) gives "78"
* Serial.print(1.23456) gives "1.23"
* Serial.print(byte(78)) gives "N" (whose ASCII value is 78)
* Serial.print('N') gives "N"
* Serial.print("Hello world.") gives "Hello world."

An optional second parameter specifies the base (format) to use; permitted values are BYTE, BIN (binary, or base 2), OCT (octal, or base 8), DEC (decimal, or base 10), HEX (hexadecimal, or base 16). For floating point numbers, this parameter specifies the number of decimal places to use. For example:
* Serial.print(78, BYTE) gives "N"
* Serial.print(78, BIN) gives "1001110"
* Serial.print(78, OCT) gives "116"
* Serial.print(78, DEC) gives "78"
* Serial.print(78, HEX) gives "4E"
* Serial.println(1.23456, 0) gives "1"
* Serial.println(1.23456, 2) gives "1.23"
* Serial.println(1.23456, 4) gives "1.2346"

Changed lines 26-82 from:
This command can take many forms:

'''Serial.print(b)'''
with no format specified, prints b as a decimal number in an ASCII string. For example,

[@
int b = 79;
Serial.print(b);@]
prints the ASCII string "79".

'''Serial.print(b, DEC)'''
prints b as a decimal number in an ASCII string. For example,

[@
int b = 79;
Serial.print(b, DEC);@]
prints the string "79".

'''Serial.print(b, HEX)'''
prints b as a hexadecimal number in an ASCII string. For example,

[@
int b = 79;
Serial.print(b, HEX);@]
prints the string "4F".

'''Serial.print(b, OCT)'''
prints b as an octal number in an ASCII string. For example,

[@
int b = 79;
Serial.print(b, OCT);@]
prints the string "117".

'''Serial.print(b, BIN)'''
prints b as a binary number in an ASCII string. For example,

[@
int b = 79;
Serial.print(b, BIN);@]
prints the string "1001111".

'''Serial.print(b, BYTE)'''
prints b as a single byte. For example,

[@
int b = 79;
Serial.print(b, BYTE);@]
returns the string "O", which is the ASCII character represented by the value 79. For more information see the [[http://www.asciitable.com |ASCII table]].

'''Serial.print(str)'''
if str is a string or an array of chars, prints str as an ASCII string. For example,

[@
Serial.print("Hello World!");@]
prints the string "Hello World!".
to:
Serial.print(val) \\
Serial.print(val, format)
Changed lines 30-34 from:

b: the byte to print, or

str: the string to print
to:
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)
Changed lines 94-102 from:
Serial.print() doesn't work on floats, so you'll need to cast them to an integral type, losing any fractional values. It is sometimes useful to multiply your float by a power of ten, to preserve some of this fractional resolution.

Be careful about doing math inside the brackets e.g.\\
[@Serial.print(x-2, DEC);@]\\
The unsigned char data type, and byte data type will yield incorrect results and act as though they are signed types i.e. type char.

The Serial.print function puts data into a buffer. It will wait for one character to send, before going on to the next character. However the function returns before sending the ''last'' character.

to:
The last character to be printed is transmitted over the serial port after Serial.print() has returned.
Changed lines 98-105 from:
* [[(Reference.)ASCIIchart|ASCII chart]]
* [[(Reference.)Serial.begin]](speed)
* [[(Reference.)Serial.available]]()
* [[(Reference.)Serial.read]]()
* [[(Reference.)Serial.println]](data)


to:
* [[(Reference.)Serial.write]]()
* [[(Reference.)Serial.println]]()


February 01, 2010, at 05:29 PM by David A. Mellis -
Changed lines 1-2 from:
!!Serial.print(data)
to:
[[Reference/Serial]]

!!print()
Deleted lines 8-13:
!!!!Parameter

data: integer types, including char, 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:18 AM by Paul Badger -
July 24, 2009, at 01:16 AM by Paul Badger -
Changed lines 10-11 from:
Printing of floats is currently supported to two places to the right of the decimal point. This may change soon.
to:
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:15 AM by Paul Badger -
Changed lines 9-11 from:
data: integer types, including char, floats
printing of floats is currently supported to two places to the right of the decimal point. This may change soon.
to:
data: integer types, including char, floats\\
Printing of floats is currently supported to two places to the right of the decimal point. This may change soon.
July 24, 2009, at 01:14 AM by Paul Badger -
Changed lines 9-10 from:
data: all integer types, including char
to:
data: integer types, including char, floats
printing of floats is currently supported to two places to the right of the decimal point. This may change soon.
October 28, 2008, at 05:36 PM by Paul Badger -
Changed lines 87-88 from:
Serial.begin(9600); // open the serial port at 9600 bps:
to:
Serial.begin(9600); // open the serial port at 9600 bps:
October 28, 2008, at 05:30 PM by Paul Badger -
Changed lines 87-88 from:
// open the serial port at 9600 bps:
Serial.begin(9600);
to:
Serial.begin(9600); // open the serial port at 9600 bps:
October 28, 2008, at 05:29 PM by Paul Badger -
Deleted lines 83-84:

October 28, 2008, at 05:29 PM by Paul Badger -
Changed lines 81-82 from:
[@/*Uses a '''for''' loop for data and prints a number in various formats.
to:
[@/*
Uses a FOR loop for data and prints a number in various formats.
October 28, 2008, at 05:28 PM by Paul Badger -
Changed line 94 from:
Serial.print("No FORMAT"); // prints a label
to:
Serial.print("NO FORMAT"); // prints a label
October 28, 2008, at 05:27 PM by Paul Badger -
Changed lines 81-83 from:
Uses a '''for''' loop for data and prints a number in various formats.

[@
to:
[@/*Uses a '''for''' loop for data and prints a number in various formats.
*/

October 28, 2008, at 05:26 PM by Paul Badger -
Added lines 81-82:
Uses a '''for''' loop for data and prints a number in various formats.
October 28, 2008, at 05:23 PM by Paul Badger -
Changed lines 82-92 from:
/*
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
to:
int x = 0; // variable
Changed lines 89-112 from:
void loop() {
// read the analog input on pin 0:
analogValue = analogRead(0);

// print it out in many formats:
Serial.print(analogValue); // print as an ASCII-encoded decimal
Serial.print("\t"); // print a tab character
Serial.print(analogValue, DEC); // print as an ASCII-encoded decimal
Serial.print("\t"); // print a tab character
Serial.print(analogValue, HEX); // print as an ASCII-encoded hexadecimal
Serial.print("\t"); // print a tab character
Serial.print(analogValue, OCT); // print as an ASCII-encoded octal
Serial.print("\t"); // print a tab character
Serial.print(analogValue, BIN); // print as an ASCII-encoded binary
Serial.print("\t"); // print a tab character
Serial.print(analogValue/4, BYTE); // print as a raw byte value (divide the
// value by 4 because analogRead() returns numbers
// from 0 to 1023, but a byte can only hold values
// up to 255)
Serial.print("\t"); // print a tab character
Serial.println(); // print a linefeed character

// delay 10 milliseconds before the next reading:
delay(10);
to:
void loop() {
// print labels
Serial.print("No FORMAT"); // prints a label
Serial.print("\t"); // prints a tab

Serial.print("DEC");
Serial.print("\t");

Serial.print("HEX");
Serial.print("\t");

Serial.print("OCT");
Serial.print("\t");

Serial.print("BIN");
Serial.print("\t");

Serial.println("BYTE");

for(x=0; x< 64; x++){ // only part of the ASCII chart, change to suit

// print it out in many formats:
Serial.print(x); // print as an ASCII-encoded decimal - same as "DEC"
Serial.print("\t"); // prints a tab

Serial.print(x, DEC); // print as an ASCII-encoded decimal
Serial.print("\t"); // prints a tab

Serial.print(x, HEX); // print as an ASCII-encoded hexadecimal
Serial.print("\t"); // prints a tab

Serial.print(x, OCT); // print as an ASCII-encoded octal
Serial.print("\t"); // prints a tab

Serial.print(x, BIN); // print as an ASCII-encoded binary
Serial.print("\t"); // prints a tab

Serial.println(x, BYTE); // prints as a raw byte value,
// then adds the carriage return with "println"
delay(200); // delay 200 milliseconds
}
Serial.println(""); // prints another carriage return
October 28, 2008, at 04:58 PM by Paul Badger -
Changed lines 131-133 from:
The Serial.Print function puts data into a buffer. It will wait for one character to send, before going on to the next character. However the function returns before sending the ''last'' character.

to:
The Serial.print function puts data into a buffer. It will wait for one character to send, before going on to the next character. However the function returns before sending the ''last'' character.

November 21, 2007, at 09:50 PM by David A. Mellis - clarifying use with floats.
Changed lines 9-10 from:
data: all integer types, including char; truncates floating point numbers to integers
to:
data: all integer types, including char
Changed lines 125-126 from:
Serial.print() truncates floats into integers, losing any fractional values. It is sometimes useful to multiply your float by a power of ten, to preserve some of this fractional resolution.
to:
Serial.print() doesn't work on floats, so you'll need to cast them to an integral type, losing any fractional values. It is sometimes useful to multiply your float by a power of ten, to preserve some of this fractional resolution.
September 08, 2007, at 12:47 AM by Paul Badger -
Changed lines 131-133 from:
The Serial.Print function puts data into a buffer. It will wait for one character to send, before going on to the next character. However the function returns before sending the '''last''' character.

to:
The Serial.Print function puts data into a buffer. It will wait for one character to send, before going on to the next character. However the function returns before sending the ''last'' character.

September 08, 2007, at 12:47 AM by Paul Badger -
Changed lines 131-133 from:
The Serial.Print function puts data into a buffer. It will wait for one character to send, before going on to the next character. However the function returns before sending the !!!last character.

to:
The Serial.Print function puts data into a buffer. It will wait for one character to send, before going on to the next character. However the function returns before sending the '''last''' character.

September 08, 2007, at 12:44 AM by Paul Badger -
Changed line 124 from:
!!!!Programming Tip / Known Issues
to:
!!!!Programming Tips / Known Issues
Changed lines 131-133 from:
to:
The Serial.Print function puts data into a buffer. It will wait for one character to send, before going on to the next character. However the function returns before sending the !!!last character.

July 19, 2007, at 05:36 AM by Paul Badger -
Changed lines 60-61 from:
returns the string "O", which is the ASCII character represented by the value 79. See the [[http://www.asciitable.com |ASCII table]] for more.
to:
returns the string "O", which is the ASCII character represented by the value 79. For more information see the [[http://www.asciitable.com |ASCII table]].
Changed lines 63-64 from:
if str is a string or an array of chars, prints str an ASCII string. For example,
to:
if str is a string or an array of chars, prints str as an ASCII string. For example,
July 19, 2007, at 05:34 AM by Paul Badger -
Changed lines 60-61 from:
returns the string "O", which is the ASII character represented by the value 79. See the [[http://www.asciitable.com |ASCII table]] for more.
to:
returns the string "O", which is the ASCII character represented by the value 79. See the [[http://www.asciitable.com |ASCII table]] for more.
July 19, 2007, at 05:30 AM by Paul Badger -
Changed line 127 from:
Also be careful about doing math inside the brackets e.g.\\
to:
Be careful about doing math inside the brackets e.g.\\
July 19, 2007, at 05:26 AM by Paul Badger -
Changed lines 127-128 from:
Also be careful about doing math inside the brackets e.g.
[@Serial.print(x-2, DEC);@]
to:
Also be careful about doing math inside the brackets e.g.\\
[@Serial.print(x-2, DEC);@]\\
July 19, 2007, at 05:25 AM by Paul Badger -
Changed lines 124-127 from:
!!!!Programming Tip
Serial.print() truncates floats into integers, losing any fractional values. It is sometimes useful to multiply your float by a power of ten, to preserve some of this fractional resolution. Just remember to convert it back on the other end before your project is launched on the Hubble Space Telescope.

to:
!!!!Programming Tip / Known Issues
Serial.print() truncates floats into integers, losing any fractional values. It is sometimes useful to multiply your float by a power of ten, to preserve some of this fractional resolution.

Also be careful about doing math inside the brackets e.g.
[@Serial.print(x-2, DEC);@]
The unsigned char data type, and byte data type will yield incorrect results and act as though they are signed types i.e. type char.

May 30, 2007, at 06:23 PM by Paul Badger -
Changed line 130 from:
* [[ASCIIchart|ASCII chart]]
to:
* [[(Reference.)ASCIIchart|ASCII chart]]
May 30, 2007, at 06:22 PM by Paul Badger -
Added lines 129-130:

* [[ASCIIchart|ASCII chart]]
April 14, 2007, at 07:37 AM by Paul Badger -
Changed lines 15-16 from:
prints b as a decimal number in an ASCII string. For example,
to:
with no format specified, prints b as a decimal number in an ASCII string. For example,
Changed lines 20-21 from:
with no specified format, defaults to decimal, and prints the ASCII string "79".
to:
prints the ASCII string "79".
April 14, 2007, at 07:33 AM by Paul Badger -
Changed lines 20-21 from:
prints the string "79".
to:
with no specified format, defaults to decimal, and prints the ASCII string "79".
April 14, 2007, at 07:30 AM by Paul Badger -
Added line 11:
!!!!Syntax
April 14, 2007, at 07:29 AM by Paul Badger -
Changed lines 9-10 from:
data
to:
data: all integer types, including char; truncates floating point numbers to integers
April 14, 2007, at 07:26 AM by Paul Badger -
Changed lines 5-6 from:
Prints a data to the serial port. This command can take many forms:
to:
Prints data to the serial port.

!!!!Parameter

data

This command can take many forms:
April 14, 2007, at 07:19 AM by Paul Badger -
Changed lines 115-117 from:
}

@]
to:
}@]
April 14, 2007, at 07:18 AM by Paul Badger -
Changed lines 119-121 from:
Serial.print() truncates floats into integers, losing any fractional values. It is sometimes useful to multiply your float by a power of ten, to preserve some of this fractional resolution. Just remember to convert it back on the other end before your project is launched on the Hubble.

to:
Serial.print() truncates floats into integers, losing any fractional values. It is sometimes useful to multiply your float by a power of ten, to preserve some of this fractional resolution. Just remember to convert it back on the other end before your project is launched on the Hubble Space Telescope.

April 14, 2007, at 07:17 AM by Paul Badger -
Changed lines 118-121 from:
to:
!!!!Programming Tip
Serial.print() truncates floats into integers, losing any fractional values. It is sometimes useful to multiply your float by a power of ten, to preserve some of this fractional resolution. Just remember to convert it back on the other end before your project is launched on the Hubble.

March 28, 2006, at 11:14 AM by David A. Mellis - Reformatted example (dividing analogValue by 4 when sending as single byte).
Changed lines 96-109 from:
Serial.print(analogValue); // print as an ASCII-encoded decimal
Serial.print("\t"); // print a tab character
Serial.print(analogValue, DEC); // print as an ASCII-encoded decimal
Serial.print("\t"); // print a tab character
Serial.print(analogValue, HEX); // print as an ASCII-encoded hexadecimal
Serial.print("\t"); // print a tab character
Serial.print(analogValue, OCT); // print as an ASCII-encoded octal
Serial.print("\t"); // print a tab character
Serial.print(analogValue, BIN); // print as an ASCII-encoded binary
Serial.print("\t"); // print a tab character
Serial.print(analogValue/4, BYTE); // print as a raw byte value (divide the value by 4 because analogRead() returns numbers from 0 to 1023, but a byte can only hold values up to 255)
Serial.print("\t"); // print a tab character
Serial.println(); // print a linefeed character
to:
Serial.print(analogValue); // print as an ASCII-encoded decimal
Serial.print("\t"); // print a tab character
Serial.print(analogValue, DEC); // print as an ASCII-encoded decimal
Serial.print("\t"); // print a tab character
Serial.print(analogValue, HEX); // print as an ASCII-encoded hexadecimal
Serial.print("\t"); // print a tab character
Serial.print(analogValue, OCT); // print as an ASCII-encoded octal
Serial.print("\t"); // print a tab character
Serial.print(analogValue, BIN); // print as an ASCII-encoded binary
Serial.print("\t"); // print a tab character
Serial.print(analogValue/4, BYTE); // print as a raw byte value (divide the
// value by 4 because analogRead() returns numbers
// from 0 to 1023, but a byte can only hold values
// up to 255)
Serial.print("\t"); // print a tab character
Serial.println(); // print a linefeed character
March 28, 2006, at 11:11 AM by David A. Mellis - Changed "returns the string ..." to "prints the string ..."
Changed lines 13-14 from:
returns the string "79".
to:
prints the string "79".
Changed lines 21-22 from:
returns the string "79".
to:
prints the string "79".
Changed lines 29-30 from:
returns the string "4F".
to:
prints the string "4F".
Changed lines 37-38 from:
returns the string "117".
to:
prints the string "117".
Changed lines 45-46 from:
returns the string "1001111".
to:
prints the string "1001111".
Changed lines 60-61 from:
returns the string "Hello World!".
to:
prints the string "Hello World!".
Changed line 106 from:
Serial.print(analogValue, BYTE); // print as a raw byte value
to:
Serial.print(analogValue/4, BYTE); // print as a raw byte value (divide the value by 4 because analogRead() returns numbers from 0 to 1023, but a byte can only hold values up to 255)
March 27, 2006, at 08:58 PM by Tom Igoe -
Deleted lines 113-114:

Changed lines 117-119 from:


to:
* [[(Reference.)Serial.begin]](speed)
* [[(Reference.)Serial.available]]()
* [[(Reference.)Serial.read]]()
* [[(Reference.)Serial.println]](data)


March 27, 2006, at 08:55 PM by Tom Igoe -
Changed lines 53-54 from:
returns the string "O", which is the ASII character represented by the value 79. See the [[http://www.asciitable.com |ASCII table]] for more..
to:
returns the string "O", which is the ASII character represented by the value 79. See the [[http://www.asciitable.com |ASCII table]] for more.
March 27, 2006, at 08:54 PM by Tom Igoe -
Changed line 52 from:
Serial.print(b, BIN);@]
to:
Serial.print(b, BYTE);@]
March 27, 2006, at 08:53 PM by Tom Igoe -
Changed lines 47-49 from:
'''Serial.print(str)'''
if str is a string or an array of chars, prints str an ASCII string. For example,
to:
'''Serial.print(b, BYTE)'''
prints b as a single byte. For example,
Added lines 51-58:
int b = 79;
Serial.print(b, BIN);@]
returns the string "O", which is the ASII character represented by the value 79. See the [[http://www.asciitable.com |ASCII table]] for more..

'''Serial.print(str)'''
if str is a string or an array of chars, prints str an ASCII string. For example,

[@
March 27, 2006, at 08:45 PM by Tom Igoe -
March 27, 2006, at 08:43 PM by Tom Igoe -
Changed lines 48-49 from:
IF str is a string or an array of chars, prints str an ASCII string. For example,
to:
if str is a string or an array of chars, prints str an ASCII string. For example,
March 27, 2006, at 08:43 PM by Tom Igoe -
Changed line 88 from:
Serial.print(analogValue); // print as an ASCII-encoded decimal
to:
Serial.print(analogValue); // print as an ASCII-encoded decimal
March 27, 2006, at 08:43 PM by Tom Igoe -
Changed line 88 from:
Serial.print(analogValue,); // print as an ASCII-encoded decimal
to:
Serial.print(analogValue); // print as an ASCII-encoded decimal
March 27, 2006, at 08:43 PM by Tom Igoe -
Added line 89:
Serial.print("\t"); // print a tab character
March 27, 2006, at 08:42 PM by Tom Igoe -
Added line 88:
Serial.print(analogValue,); // print as an ASCII-encoded decimal
March 27, 2006, at 08:42 PM by Tom Igoe -
Changed line 7 from:
'''Serial.print(b, DEC)'''
to:
'''Serial.print(b)'''
Changed line 12 from:
Serial.print(b, DEC);@]
to:
Serial.print(b);@]
Changed lines 15-17 from:
'''Serial.print(int b, HEX)'''
prints b as a hexadecimal number in an ASCII string. For example,
to:
'''Serial.print(b, DEC)'''
prints b as a decimal number in an ASCII string. For example,
Added lines 20-27:
Serial.print(b, DEC);@]
returns the string "79".

'''Serial.print(b, HEX)'''
prints b as a hexadecimal number in an ASCII string. For example,

[@
int b = 79;
March 27, 2006, at 08:41 PM by Tom Igoe -
Changed line 7 from:
'''Serial.print(int b, DEC)'''
to:
'''Serial.print(b, DEC)'''
Changed line 23 from:
'''Serial.print(int b, OCT)'''
to:
'''Serial.print(b, OCT)'''
Changed line 31 from:
'''Serial.print(int b, BIN)'''
to:
'''Serial.print(b, BIN)'''
March 27, 2006, at 08:40 PM by Tom Igoe -
Changed lines 89-90 from:
Serial.print("\t"); // print a tab character
Serial.print(analogValue);
to:
Serial.print("\t"); // print a tab character
March 27, 2006, at 08:39 PM by Tom Igoe -
Added lines 56-100:
!!!!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.print(analogValue, DEC); // print as an ASCII-encoded decimal
Serial.print("\t"); // print a tab character
Serial.print(analogValue, HEX); // print as an ASCII-encoded hexadecimal
Serial.print("\t"); // print a tab character
Serial.print(analogValue, OCT); // print as an ASCII-encoded octal
Serial.print("\t"); // print a tab character
Serial.print(analogValue, BIN); // print as an ASCII-encoded binary
Serial.print("\t"); // print a tab character
Serial.print(analogValue, BYTE); // print as a raw byte value
Serial.print("\t"); // print a tab character
Serial.print(analogValue);
Serial.println(); // print a linefeed character

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



@]
March 27, 2006, at 08:38 PM by Tom Igoe -
Changed lines 28-29 from:
Serial.print(b, OCT);
@]
to:
Serial.print(b, OCT);@]
Changed lines 36-37 from:
Serial.print(b, BIN);
@]
to:
Serial.print(b, BIN);@]
Changed lines 43-44 from:
Serial.print("Hello World!");
@]
to:
Serial.print("Hello World!");@]
Changed lines 57-59 from:
*

to:


March 27, 2006, at 08:38 PM by Tom Igoe -
Changed lines 12-13 from:
Serial.print(b, DEC);
@]
to:
Serial.print(b, DEC);@]
Changed lines 20-21 from:
Serial.print(b, HEX);
@]
to:
Serial.print(b, HEX);@]
March 27, 2006, at 08:38 PM by Tom Igoe -
Added lines 43-50:
'''Serial.print(str)'''
IF str is a string or an array of chars, prints str an ASCII string. For example,

[@
Serial.print("Hello World!");
@]
returns the string "Hello World!".
March 27, 2006, at 08:36 PM by Tom Igoe -
Deleted line 13:
Deleted line 22:
Deleted line 31:
Deleted line 40:
Changed lines 45-46 from:
b: the byte to print
to:
b: the byte to print, or

str: the string to print
Changed lines 54-63 from:
* [[printMode]]
* [[printString]]
* [[printInteger]]
* [[printHex]]
* [[printOctal]]
* [[printBinary]]
* [[printNewline]]


[[HomePage | Reference Home]]
to:
*


[[Reference.HomePage | Reference Home]]
March 27, 2006, at 08:35 PM by Tom Igoe -
Added lines 1-65:
!!Serial.print(data)

!!!!Description

Prints a data to the serial port. This command can take many forms:

'''Serial.print(int b, DEC)'''
prints b as a decimal number in an ASCII string. For example,

[@
int b = 79;
Serial.print(b, DEC);
@]

returns the string "79".

'''Serial.print(int b, HEX)'''
prints b as a hexadecimal number in an ASCII string. For example,

[@
int b = 79;
Serial.print(b, HEX);
@]

returns the string "4F".

'''Serial.print(int b, OCT)'''
prints b as an octal number in an ASCII string. For example,

[@
int b = 79;
Serial.print(b, OCT);
@]

returns the string "117".

'''Serial.print(int b, BIN)'''
prints b as a binary number in an ASCII string. For example,

[@
int b = 79;
Serial.print(b, BIN);
@]

returns the string "1001111".

!!!!Parameters

b: the byte to print

!!!!Returns

None

!!!!See also
* [[printMode]]
* [[printString]]
* [[printInteger]]
* [[printHex]]
* [[printOctal]]
* [[printBinary]]
* [[printNewline]]


[[HomePage | Reference Home]]

Share