1
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
4
<title>Arduino - Println </title>
5
<link rel='stylesheet' href='arduino.css' type='text/css' />
6
<meta name="verify-v1" content="TtxFIEJAB6zdJ509wLxjnapQzKAMNm9u0Wj4ho6wxIY=" />
12
<div class="title"><a href="http://www.arduino.cc"/>Arduino</a></div>
14
<!-- SiteSearch Google -->
0
15
<FORM method=GET action="http://www.google.com/search">
1
16
<input type=hidden name=ie value=UTF-8>
2
17
<input type=hidden name=oe value=UTF-8>
3
18
<INPUT TYPE=text name=q size=25 maxlength=255 value="">
4
19
<INPUT type=submit name=btnG VALUE="search">
5
20
<input type=hidden name=domains value="http://www.arduino.cc/">
21
<input type=hidden name=sitesearch value="http://www.arduino.cc/">
6
23
<!-- SiteSearch Google -->
28
<div id="pagenav" style="text-align: right">
29
<div style="float: left;">
30
<p><a class='wikilink' href='http://arduino.cc/en/Main/Buy'>Buy</a>
32
<a class='wikilink' href='http://arduino.cc/en/Main/Software'>Download</a>
34
<a class='wikilink' href='Guide_index.html'>Getting Started</a>
36
<a class='wikilink' href='http://arduino.cc/en/Tutorial/HomePage'>Learning</a>
38
<a class='wikilink' href='index.html'>Reference</a>
40
<a class='wikilink' href='http://arduino.cc/en/Main/Hardware'>Hardware</a>
42
<a class='wikilink' href='FAQ.html'>FAQ</a>
44
<p class='vspace'></p>
47
<a class="urllink" href="http://www.arduino.cc/blog/" rel="nofollow">Blog »</a> |
48
<a class="urllink" href="http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl" rel="nofollow">Forum »</a> |
49
<a class="urllink" href="http://www.arduino.cc/playground/" rel="nofollow">Playground »</a>
55
<h2>Serial.println(data)</h2>
57
<p>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 <a class='wikilink' href='Serial_Print.html'>Serial.print</a>():
59
<p class='vspace'></p><p><strong>Serial.println(b)</strong>
60
prints b as a decimal number in an ASCII string followed by a carriage return and a linefeed.
62
<p class='vspace'></p><p><strong>Serial.println(b, DEC)</strong>
63
prints b as a decimal number in an ASCII string followed by a carriage return and a linefeed.
65
<p class='vspace'></p><p><strong>Serial.println(b, HEX)</strong>
66
prints b as a hexadecimal number in an ASCII string followed by a carriage return and a linefeed.
68
<p class='vspace'></p><p><strong>Serial.println(b, OCT)</strong>
69
prints b as an octal number in an ASCII string followed by a carriage return and a linefeed.
71
<p class='vspace'></p><p><strong>Serial.println(b, BIN)</strong>
72
prints b as a binary number in an ASCII string followed by a carriage return and a linefeed.
74
<p class='vspace'></p><p><strong>Serial.print(b, BYTE)</strong>
75
prints b as a single byte followed by a carriage return and a linefeed.
77
<p class='vspace'></p><p><strong>Serial.println(str)</strong>
78
if str is a string or an array of chars, prints str an ASCII string.
80
<p class='vspace'></p><p><strong>Serial.println()</strong>
81
just prints a carriage return and a linefeed.
83
<p class='vspace'></p><h4>Parameter</h4>
84
<p>data types: integer types, including char, strings (char arrays) & floats<br />Printing of floats is supported with a precision of two places to the right of the decimal point.<br />This may change soon.
86
<p class='vspace'></p><h4>Returns</h4>
89
<p class='vspace'></p><h4>Example:</h4>
94
reads an analog input on analog in 0, prints the value out.
100
int analogValue = 0; // variable to hold the analog value
103
// open the serial port at 9600 bps:
108
// read the analog input on pin 0:
109
analogValue = analogRead(0);
111
// print it out in many formats:
112
Serial.println(analogValue); // print as an ASCII-encoded decimal
113
Serial.println(analogValue, DEC); // print as an ASCII-encoded decimal
114
Serial.println(analogValue, HEX); // print as an ASCII-encoded hexadecimal
115
Serial.println(analogValue, OCT); // print as an ASCII-encoded octal
116
Serial.println(analogValue, BIN); // print as an ASCII-encoded binary
117
Serial.println(analogValue, BYTE); // print as a raw byte value
119
// delay 10 milliseconds before the next reading:
123
<p class='vspace'></p><h4>Programming Tip / Known Issues</h4>
124
<p>see <a class='wikilink' href='Serial_Print.html'>Serial.print</a>
126
<p class='vspace'></p><h4>See also</h4>
127
<ul><li><a class='wikilink' href='ASCIIchart.html'>ASCII chart</a>
128
</li><li><a class='wikilink' href='Serial_Begin.html'>Serial.begin</a>(speed)
129
</li><li><a class='wikilink' href='Serial_Available.html'>Serial.available</a>()
130
</li><li><a class='wikilink' href='Serial_Read.html'>Serial.read</a>()
131
</li><li><a class='wikilink' href='Serial_Print.html'>Serial.print</a>(data)
132
</li></ul><p class='vspace'></p><p><a class='wikilink' href='index.html'>Reference Home</a>
138
<div id="pagefooter">
139
<a href='Serial_Println?action=edit.html'>Edit Page</a> | <a href='Serial_Println?action=diff.html'>Page History</a> | <a href='Serial_Println?action=print.html' target='_blank'>Printable View</a> | <a href='http://arduino.cc/en/Site/AllRecentChanges'>All Recent Site Changes</a>
141
<!--/PageFooterFmt-->