~ubuntu-branches/ubuntu/precise/arduino/precise

« back to all changes in this revision

Viewing changes to reference/Serial_Println.html

  • Committer: Bazaar Package Importer
  • Author(s): Scott Howard
  • Date: 2010-04-13 22:32:24 UTC
  • Revision ID: james.westby@ubuntu.com-20100413223224-jduxnd0xxnkkda02
Tags: upstream-0018+dfsg
ImportĀ upstreamĀ versionĀ 0018+dfsg

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 
2
<html>
 
3
<head>
 
4
  <title>Arduino - Println </title>
 
5
  <link rel='stylesheet' href='arduino.css' type='text/css' />
 
6
  <meta name="verify-v1" content="TtxFIEJAB6zdJ509wLxjnapQzKAMNm9u0Wj4ho6wxIY=" />
 
7
</head>
 
8
<body>
 
9
<div id="page">
 
10
<!--PageHeaderFmt-->
 
11
<div id="pageheader">
 
12
  <div class="title"><a href="http://www.arduino.cc"/>Arduino</a></div>
 
13
  <div class="search">
 
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/">
 
22
    </FORM>
6
23
   <!-- SiteSearch Google -->
 
24
  </div>
 
25
</div>
 
26
<!--/PageHeaderFmt-->
 
27
<!--PageLeftFmt-->
 
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>
 
31
|
 
32
<a class='wikilink' href='http://arduino.cc/en/Main/Software'>Download</a>
 
33
|
 
34
<a class='wikilink' href='Guide_index.html'>Getting Started</a>
 
35
|
 
36
<a class='wikilink' href='http://arduino.cc/en/Tutorial/HomePage'>Learning</a>
 
37
|
 
38
<a class='wikilink' href='index.html'>Reference</a>
 
39
|
 
40
<a class='wikilink' href='http://arduino.cc/en/Main/Hardware'>Hardware</a>
 
41
|
 
42
<a class='wikilink' href='FAQ.html'>FAQ</a>
 
43
</p>
 
44
<p class='vspace'></p>
 
45
 
 
46
  </div>
 
47
  <a class="urllink" href="http://www.arduino.cc/blog/" rel="nofollow">Blog &raquo;</a> |
 
48
  <a class="urllink" href="http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl" rel="nofollow">Forum &raquo;</a> |
 
49
  <a class="urllink" href="http://www.arduino.cc/playground/" rel="nofollow">Playground &raquo;</a>
 
50
</div>
 
51
<!--/PageLeftFmt-->
 
52
<div id="pagetext">
 
53
<!--PageText-->
 
54
<div id='wikitext'>
 
55
<h2>Serial.println(data)</h2>
 
56
<h4>Description</h4>
 
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>():
 
58
</p>
 
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. 
 
61
</p>
 
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.
 
64
</p>
 
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. 
 
67
</p>
 
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. 
 
70
</p>
 
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.
 
73
</p>
 
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.  
 
76
</p>
 
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. 
 
79
</p>
 
80
<p class='vspace'></p><p><strong>Serial.println()</strong> 
 
81
just prints a carriage return and a linefeed.
 
82
</p>
 
83
<p class='vspace'></p><h4>Parameter</h4>
 
84
<p>data types: integer types, including char, strings (char arrays) &amp; 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.
 
85
</p>
 
86
<p class='vspace'></p><h4>Returns</h4>
 
87
<p>None
 
88
</p>
 
89
<p class='vspace'></p><h4>Example:</h4>
 
90
<pre>
 
91
/*
 
92
  Analog input
 
93
 
 
94
 reads an analog input on analog in 0, prints the value out.
 
95
 
 
96
 created 24 March 2006
 
97
 by Tom Igoe
 
98
 */
 
99
 
 
100
int analogValue = 0;    // variable to hold the analog value
 
101
 
 
102
void setup() {
 
103
  // open the serial port at 9600 bps:
 
104
  Serial.begin(9600);
 
105
}
 
106
 
 
107
void loop() {
 
108
  // read the analog input on pin 0:
 
109
  analogValue = analogRead(0);
 
110
 
 
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
 
118
 
 
119
  // delay 10 milliseconds before the next reading:
 
120
  delay(10);
 
121
}
 
122
</pre>
 
123
<p class='vspace'></p><h4>Programming Tip / Known Issues</h4>
 
124
<p>see <a class='wikilink' href='Serial_Print.html'>Serial.print</a>
 
125
</p>
 
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>
 
133
</p>
 
134
</div>
 
135
 
 
136
</div>
 
137
<!--PageFooterFmt-->
 
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>
 
140
</div>
 
141
<!--/PageFooterFmt-->
 
142
</div>
 
143
</body>
 
144
</html>