1
0
mirror of https://github.com/esp8266/Arduino.git synced 2025-08-17 06:42:21 +03:00

Corretions and refinements to the String examples

This commit is contained in:
Federico Vanzati
2012-04-06 12:59:54 +02:00
parent ade4893f58
commit 383ac95f3e
1111 changed files with 244427 additions and 223 deletions

View File

@@ -0,0 +1,112 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>Arduino Reference - Abs </title>
<link rel="shortcut icon" type="image/x-icon" href="http://arduino.cc/en/favicon.png">
<link rel='stylesheet' href='arduinoWideRender.css'
type='text/css' />
<!--HeaderText--><style type='text/css'><!--
ul, ol, pre, dl, p { margin-top:0px; margin-bottom:0px; }
code { white-space: nowrap; }
.vspace { margin-top:1.33em; }
.indent { margin-left:40px; }
.outdent { margin-left:40px; text-indent:-40px; }
a.createlinktext { text-decoration:none; border-bottom:1px dotted gray; }
a.createlink { text-decoration:none; position:relative; top:-0.5em;
font-weight:bold; font-size:smaller; border-bottom:none; }
img { border:0px; }
.editconflict { color:green;
font-style:italic; margin-top:1.33em; margin-bottom:1.33em; }
table.markup { border: 2px dotted #ccf; width:90%; }
td.markup1, td.markup2 { padding-left:10px; padding-right:10px; }
td.markup1 { border-bottom: 1px solid #ccf; }
div.faq { margin-left:2em; }
div.faq p.question { margin: 1em 0 0.75em -2em; font-weight:bold; }
div.faq hr { margin-left: -2em; }
.frame
{ border:1px solid #cccccc; padding:4px; background-color:#f9f9f9; }
.lfloat { float:left; margin-right:0.5em; }
.rfloat { float:right; margin-left:0.5em; }
a.varlink { text-decoration:none; }
--></style> <meta name='robots' content='index,follow' />
<meta name="verify-v1" content="TtxFIEJAB6zdJ509wLxjnapQzKAMNm9u0Wj4ho6wxIY=" />
</head>
<body>
<div id="page">
<!--PageHeaderFmt-->
<div id="pageheader">
<div class="title"><a href='http://arduino.cc/en'>Arduino</a></div>
</div>
<!--/PageHeaderFmt-->
<!--PageLeftFmt-->
<div id="pagenav">
<div id="navbar">
<p><a class='wikilink' href='http://arduino.cc/en/Main/Buy'>Buy</a>
<a class='wikilink' href='http://arduino.cc/en/Main/Software'>Download</a>
<a class='wikilink' href='Guide_index.html'>Getting Started</a>
<a class='wikilink' href='http://arduino.cc/en/Tutorial/HomePage'>Learning</a>
<a class='wikilink' href='index.html'>Reference</a>
<a class='wikilink' href='http://arduino.cc/en/Main/Hardware'>Hardware</a>
<a class='wikilink' href='FAQ.html'>FAQ</a>
</p>
<p class='vspace'></p>
</div>
</div>
<!--/PageLeftFmt-->
<div id="pagetext">
<!--PageText-->
<div id='wikitext'>
<p><strong>Reference</strong> &nbsp; <a class='wikilink' href='index.html'>Language</a> | <a class='wikilink' href='Libraries.html'>Libraries</a> | <a class='wikilink' href='Comparison.html'>Comparison</a> | <a class='wikilink' href='Changes.html'>Changes</a>
</p>
<p class='vspace'></p><h2>abs(x)</h2>
<h4>Description</h4>
<p>Computes the absolute value of a number.
</p>
<p class='vspace'></p><h4>Parameters</h4>
<p>x: the number
</p>
<p class='vspace'></p><h4>Returns</h4>
<p><strong>x</strong>: if <strong>x</strong> is greater than or equal to 0.
</p>
<p class='vspace'></p><p><strong>-x</strong>: if <strong>x</strong> is less than 0.
</p>
<p class='vspace'></p><h4>Warning</h4>
<p>Because of the way the abs() function is implemented, avoid using other functions inside the brackets, it may lead to incorrect results.
</p>
<p class='vspace'></p><pre>
abs(a++); // avoid this - yields incorrect results
a++; // use this instead -
abs(a); // keep other math outside the function
</pre>
<p class='vspace'></p><p><a class='wikilink' href='index.html'>Reference Home</a>
</p>
<p class='vspace'></p><p><em>Corrections, suggestions, and new documentation should be posted to the <a class='urllink' href='http://arduino.cc/forum/index.php/board,23.0.html' rel='nofollow'>Forum</a>.</em>
</p>
<p class='vspace'></p><p>The text of the Arduino reference is licensed under a
<a class='urllink' href='http://creativecommons.org/licenses/by-sa/3.0/' rel='nofollow'>Creative Commons Attribution-ShareAlike 3.0 License</a>. Code samples in the reference are released into the public domain.
</p>
</div>
</div>
<!--PageFooterFmt-->
<div id="pagefooter">
&copy;Arduino |
<a href='#'>Edit Page</a> | <a href='#'>Page History</a> | <a href='#' target='_blank'>Printable View</a> | <a href='http://arduino.cc/en/Site/AllRecentChanges'>All Recent Site Changes</a>
</div>
<!--/PageFooterFmt-->
</div>
</body>
</html>

View File

@@ -0,0 +1,129 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>Arduino Reference - AnalogRead </title>
<link rel="shortcut icon" type="image/x-icon" href="http://arduino.cc/en/favicon.png">
<link rel='stylesheet' href='arduinoWideRender.css'
type='text/css' />
<!--HeaderText--><style type='text/css'><!--
ul, ol, pre, dl, p { margin-top:0px; margin-bottom:0px; }
code { white-space: nowrap; }
.vspace { margin-top:1.33em; }
.indent { margin-left:40px; }
.outdent { margin-left:40px; text-indent:-40px; }
a.createlinktext { text-decoration:none; border-bottom:1px dotted gray; }
a.createlink { text-decoration:none; position:relative; top:-0.5em;
font-weight:bold; font-size:smaller; border-bottom:none; }
img { border:0px; }
.editconflict { color:green;
font-style:italic; margin-top:1.33em; margin-bottom:1.33em; }
table.markup { border: 2px dotted #ccf; width:90%; }
td.markup1, td.markup2 { padding-left:10px; padding-right:10px; }
td.markup1 { border-bottom: 1px solid #ccf; }
div.faq { margin-left:2em; }
div.faq p.question { margin: 1em 0 0.75em -2em; font-weight:bold; }
div.faq hr { margin-left: -2em; }
.frame
{ border:1px solid #cccccc; padding:4px; background-color:#f9f9f9; }
.lfloat { float:left; margin-right:0.5em; }
.rfloat { float:right; margin-left:0.5em; }
a.varlink { text-decoration:none; }
--></style> <meta name='robots' content='index,follow' />
<meta name="verify-v1" content="TtxFIEJAB6zdJ509wLxjnapQzKAMNm9u0Wj4ho6wxIY=" />
</head>
<body>
<div id="page">
<!--PageHeaderFmt-->
<div id="pageheader">
<div class="title"><a href='http://arduino.cc/en'>Arduino</a></div>
</div>
<!--/PageHeaderFmt-->
<!--PageLeftFmt-->
<div id="pagenav">
<div id="navbar">
<p><a class='wikilink' href='http://arduino.cc/en/Main/Buy'>Buy</a>
<a class='wikilink' href='http://arduino.cc/en/Main/Software'>Download</a>
<a class='wikilink' href='Guide_index.html'>Getting Started</a>
<a class='wikilink' href='http://arduino.cc/en/Tutorial/HomePage'>Learning</a>
<a class='wikilink' href='index.html'>Reference</a>
<a class='wikilink' href='http://arduino.cc/en/Main/Hardware'>Hardware</a>
<a class='wikilink' href='FAQ.html'>FAQ</a>
</p>
<p class='vspace'></p>
</div>
</div>
<!--/PageLeftFmt-->
<div id="pagetext">
<!--PageText-->
<div id='wikitext'>
<p><strong>Reference</strong> &nbsp; <a class='wikilink' href='index.html'>Language</a> | <a class='wikilink' href='Libraries.html'>Libraries</a> | <a class='wikilink' href='Comparison.html'>Comparison</a> | <a class='wikilink' href='Changes.html'>Changes</a>
</p>
<p class='vspace'></p><h2>analogRead()</h2>
<h4>Description</h4>
<p>Reads the value from the specified analog pin. The Arduino board contains a 6 channel (8 channels on the Mini and Nano, 16 on the Mega), 10-bit analog to digital converter. This means that it will map input voltages between 0 and 5 volts into integer values between 0 and 1023. This yields a resolution between readings of: 5 volts / 1024 units or, .0049 volts (4.9 mV) per unit. The input range and resolution can be changed using <a class='wikilink' href='AnalogReference.html'>analogReference</a>().
</p>
<p class='vspace'></p><p>It takes about 100 microseconds (0.0001 s) to read an analog input, so the maximum reading rate is about 10,000 times a second.
</p>
<p class='vspace'></p><h4>Syntax</h4>
<p>analogRead(pin)
</p>
<p class='vspace'></p><h4>Parameters</h4>
<p>pin: the number of the analog input pin to read from (0 to 5 on most boards, 0 to 7 on the Mini and Nano, 0 to 15 on the Mega)
</p>
<p class='vspace'></p><h4>Returns</h4>
<p>int (0 to 1023)
</p>
<p class='vspace'></p><h4>Note</h4>
<p>If the analog input pin is not connected to anything, the value returned by analogRead() will fluctuate based on a number of factors (e.g. the values of the other analog inputs, how close your hand is to the board, etc.).
</p>
<p class='vspace'></p><h4>Example</h4>
<pre>
int analogPin = 3; // potentiometer wiper (middle terminal) connected to analog pin 3
// outside leads to ground and +5V
int val = 0; // variable to store the value read
void setup()
{
Serial.begin(9600); // setup serial
}
void loop()
{
val = analogRead(analogPin); // read the input pin
Serial.println(val); // debug value
}
</pre>
<p class='vspace'></p><h4>See also</h4>
<ul><li><a class='wikilink' href='AnalogReference.html'>analogReference</a>()
</li><li><a class='wikilink' href='http://arduino.cc/en/Tutorial/AnalogInputPins'>Tutorial: Analog Input Pins</a>
</li></ul><p><a class='wikilink' href='index.html'>Reference Home</a>
</p>
<p class='vspace'></p><p><em>Corrections, suggestions, and new documentation should be posted to the <a class='urllink' href='http://arduino.cc/forum/index.php/board,23.0.html' rel='nofollow'>Forum</a>.</em>
</p>
<p class='vspace'></p><p>The text of the Arduino reference is licensed under a
<a class='urllink' href='http://creativecommons.org/licenses/by-sa/3.0/' rel='nofollow'>Creative Commons Attribution-ShareAlike 3.0 License</a>. Code samples in the reference are released into the public domain.
</p>
</div>
</div>
<!--PageFooterFmt-->
<div id="pagefooter">
&copy;Arduino |
<a href='#'>Edit Page</a> | <a href='#'>Page History</a> | <a href='#' target='_blank'>Printable View</a> | <a href='http://arduino.cc/en/Site/AllRecentChanges'>All Recent Site Changes</a>
</div>
<!--/PageFooterFmt-->
</div>
</body>
</html>

View File

@@ -0,0 +1,116 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>Arduino Reference - AnalogReference </title>
<link rel="shortcut icon" type="image/x-icon" href="http://arduino.cc/en/favicon.png">
<link rel='stylesheet' href='arduinoWideRender.css'
type='text/css' />
<!--HeaderText--><style type='text/css'><!--
ul, ol, pre, dl, p { margin-top:0px; margin-bottom:0px; }
code { white-space: nowrap; }
.vspace { margin-top:1.33em; }
.indent { margin-left:40px; }
.outdent { margin-left:40px; text-indent:-40px; }
a.createlinktext { text-decoration:none; border-bottom:1px dotted gray; }
a.createlink { text-decoration:none; position:relative; top:-0.5em;
font-weight:bold; font-size:smaller; border-bottom:none; }
img { border:0px; }
.editconflict { color:green;
font-style:italic; margin-top:1.33em; margin-bottom:1.33em; }
table.markup { border: 2px dotted #ccf; width:90%; }
td.markup1, td.markup2 { padding-left:10px; padding-right:10px; }
td.markup1 { border-bottom: 1px solid #ccf; }
div.faq { margin-left:2em; }
div.faq p.question { margin: 1em 0 0.75em -2em; font-weight:bold; }
div.faq hr { margin-left: -2em; }
.frame
{ border:1px solid #cccccc; padding:4px; background-color:#f9f9f9; }
.lfloat { float:left; margin-right:0.5em; }
.rfloat { float:right; margin-left:0.5em; }
a.varlink { text-decoration:none; }
--></style> <meta name='robots' content='index,follow' />
<meta name="verify-v1" content="TtxFIEJAB6zdJ509wLxjnapQzKAMNm9u0Wj4ho6wxIY=" />
</head>
<body>
<div id="page">
<!--PageHeaderFmt-->
<div id="pageheader">
<div class="title"><a href='http://arduino.cc/en'>Arduino</a></div>
</div>
<!--/PageHeaderFmt-->
<!--PageLeftFmt-->
<div id="pagenav">
<div id="navbar">
<p><a class='wikilink' href='http://arduino.cc/en/Main/Buy'>Buy</a>
<a class='wikilink' href='http://arduino.cc/en/Main/Software'>Download</a>
<a class='wikilink' href='Guide_index.html'>Getting Started</a>
<a class='wikilink' href='http://arduino.cc/en/Tutorial/HomePage'>Learning</a>
<a class='wikilink' href='index.html'>Reference</a>
<a class='wikilink' href='http://arduino.cc/en/Main/Hardware'>Hardware</a>
<a class='wikilink' href='FAQ.html'>FAQ</a>
</p>
<p class='vspace'></p>
</div>
</div>
<!--/PageLeftFmt-->
<div id="pagetext">
<!--PageText-->
<div id='wikitext'>
<p><strong>Reference</strong> &nbsp; <a class='wikilink' href='index.html'>Language</a> | <a class='wikilink' href='Libraries.html'>Libraries</a> | <a class='wikilink' href='Comparison.html'>Comparison</a> | <a class='wikilink' href='Changes.html'>Changes</a>
</p>
<p class='vspace'></p><h2>analogReference(type)</h2>
<h4>Description</h4>
<p>Configures the reference voltage used for analog input (i.e. the value used as the top of the input range). The options are:
</p>
<p class='vspace'></p><ul><li>DEFAULT: the default analog reference of 5 volts (on 5V Arduino boards) or 3.3 volts (on 3.3V Arduino boards)
</li><li>INTERNAL: an built-in reference, equal to 1.1 volts on the <span class='wikiword'>ATmega168</span> or <span class='wikiword'>ATmega328</span> and 2.56 volts on the <span class='wikiword'>ATmega8</span> (<em>not available on the Arduino Mega</em>)
</li><li><span class='wikiword'>INTERNAL1V1</span>: a built-in 1.1V reference (<em>Arduino Mega only</em>)
</li><li><span class='wikiword'>INTERNAL2V56</span>: a built-in 2.56V reference (<em>Arduino Mega only</em>)
</li><li>EXTERNAL: the voltage applied to the AREF pin (<strong>0 to 5V only</strong>) is used as the reference.
</li></ul><p class='vspace'></p><h4>Parameters</h4>
<p>type: which type of reference to use (DEFAULT, INTERNAL, <span class='wikiword'>INTERNAL1V1</span>, <span class='wikiword'>INTERNAL2V56</span>, or EXTERNAL).
</p>
<p class='vspace'></p><h4>Returns</h4>
<p>None.
</p>
<p class='vspace'></p><h4>Note</h4>
<p>After changing the analog reference, the first few readings from analogRead() may not be accurate.
</p>
<p class='vspace'></p><h4>Warning</h4>
<p><strong>Don't use anything less than 0V or more than 5V for external reference voltage on the AREF pin! If you're using an external reference on the AREF pin, you must set the analog reference to EXTERNAL before calling analogRead().</strong> Otherwise, you will short together the active reference voltage (internally generated) and the AREF pin, possibly damaging the microcontroller on your Arduino board.
</p>
<p class='vspace'></p><p>Alternatively, you can connect the external reference voltage to the AREF pin through a 5K resistor, allowing you to switch between external and internal reference voltages. Note that the resistor will alter the voltage that gets used as the reference because there is an internal 32K resistor on the AREF pin. The two act as a voltage divider, so, for example, 2.5V applied through the resistor will yield 2.5 * 32 / (32 + 5) = ~2.2V at the AREF pin.
</p>
<p class='vspace'></p><h4>See also</h4>
<ul><li><a class='wikilink' href='http://arduino.cc/en/Tutorial/AnalogInputPins'>Description of the analog input pins</a>
</li><li><a class='wikilink' href='AnalogRead.html'>analogRead</a>()
</li></ul><p class='vspace'></p><p><a class='wikilink' href='index.html'>Reference Home</a>
</p>
<p class='vspace'></p><p><em>Corrections, suggestions, and new documentation should be posted to the <a class='urllink' href='http://arduino.cc/forum/index.php/board,23.0.html' rel='nofollow'>Forum</a>.</em>
</p>
<p class='vspace'></p><p>The text of the Arduino reference is licensed under a
<a class='urllink' href='http://creativecommons.org/licenses/by-sa/3.0/' rel='nofollow'>Creative Commons Attribution-ShareAlike 3.0 License</a>. Code samples in the reference are released into the public domain.
</p>
</div>
</div>
<!--PageFooterFmt-->
<div id="pagefooter">
&copy;Arduino |
<a href='#'>Edit Page</a> | <a href='#'>Page History</a> | <a href='#' target='_blank'>Printable View</a> | <a href='http://arduino.cc/en/Site/AllRecentChanges'>All Recent Site Changes</a>
</div>
<!--/PageFooterFmt-->
</div>
</body>
</html>

View File

@@ -0,0 +1,135 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>Arduino Reference - AnalogWrite </title>
<link rel="shortcut icon" type="image/x-icon" href="http://arduino.cc/en/favicon.png">
<link rel='stylesheet' href='arduinoWideRender.css'
type='text/css' />
<!--HeaderText--><style type='text/css'><!--
ul, ol, pre, dl, p { margin-top:0px; margin-bottom:0px; }
code { white-space: nowrap; }
.vspace { margin-top:1.33em; }
.indent { margin-left:40px; }
.outdent { margin-left:40px; text-indent:-40px; }
a.createlinktext { text-decoration:none; border-bottom:1px dotted gray; }
a.createlink { text-decoration:none; position:relative; top:-0.5em;
font-weight:bold; font-size:smaller; border-bottom:none; }
img { border:0px; }
.editconflict { color:green;
font-style:italic; margin-top:1.33em; margin-bottom:1.33em; }
table.markup { border: 2px dotted #ccf; width:90%; }
td.markup1, td.markup2 { padding-left:10px; padding-right:10px; }
td.markup1 { border-bottom: 1px solid #ccf; }
div.faq { margin-left:2em; }
div.faq p.question { margin: 1em 0 0.75em -2em; font-weight:bold; }
div.faq hr { margin-left: -2em; }
.frame
{ border:1px solid #cccccc; padding:4px; background-color:#f9f9f9; }
.lfloat { float:left; margin-right:0.5em; }
.rfloat { float:right; margin-left:0.5em; }
a.varlink { text-decoration:none; }
--></style> <meta name='robots' content='index,follow' />
<meta name="verify-v1" content="TtxFIEJAB6zdJ509wLxjnapQzKAMNm9u0Wj4ho6wxIY=" />
</head>
<body>
<div id="page">
<!--PageHeaderFmt-->
<div id="pageheader">
<div class="title"><a href='http://arduino.cc/en'>Arduino</a></div>
</div>
<!--/PageHeaderFmt-->
<!--PageLeftFmt-->
<div id="pagenav">
<div id="navbar">
<p><a class='wikilink' href='http://arduino.cc/en/Main/Buy'>Buy</a>
<a class='wikilink' href='http://arduino.cc/en/Main/Software'>Download</a>
<a class='wikilink' href='Guide_index.html'>Getting Started</a>
<a class='wikilink' href='http://arduino.cc/en/Tutorial/HomePage'>Learning</a>
<a class='wikilink' href='index.html'>Reference</a>
<a class='wikilink' href='http://arduino.cc/en/Main/Hardware'>Hardware</a>
<a class='wikilink' href='FAQ.html'>FAQ</a>
</p>
<p class='vspace'></p>
</div>
</div>
<!--/PageLeftFmt-->
<div id="pagetext">
<!--PageText-->
<div id='wikitext'>
<p><strong>Reference</strong> &nbsp; <a class='wikilink' href='index.html'>Language</a> | <a class='wikilink' href='Libraries.html'>Libraries</a> | <a class='wikilink' href='Comparison.html'>Comparison</a> | <a class='wikilink' href='Changes.html'>Changes</a>
</p>
<p class='vspace'></p><h2>analogWrite()</h2>
<h4>Description</h4>
<p>Writes an analog value (<a class='wikilink' href='http://arduino.cc/en/Tutorial/PWM'>PWM wave</a>) to a pin. Can be used to light a LED at varying brightnesses or drive a motor at various speeds. After a call to <strong>analogWrite()</strong>, the pin will generate a steady square wave of the specified duty cycle until the next call to <strong>analogWrite()</strong> (or a call to <strong>digitalRead()</strong> or <strong>digitalWrite()</strong> on the same pin). The frequency of the PWM signal is approximately 490 Hz.
</p>
<p class='vspace'></p><p>On most Arduino boards (those with the <span class='wikiword'>ATmega168</span> or <span class='wikiword'>ATmega328</span>), this function works on pins 3, 5, 6, 9, 10, and 11. On the Arduino Mega, it works on pins 2 through 13. Older Arduino boards with an <span class='wikiword'>ATmega8</span> only support analogWrite() on pins 9, 10, and 11. You do not need to call pinMode() to set the pin as an output before calling analogWrite().
</p>
<p class='vspace'></p><p>The <em>analogWrite</em> function has nothing whatsoever to do with the analog pins or the <em>analogRead</em> function.
</p>
<p class='vspace'></p><h4>Syntax</h4>
<p>analogWrite(pin, value)
</p>
<p class='vspace'></p><h4>Parameters</h4>
<p>pin: the pin to write to.
</p>
<p class='vspace'></p><p>value: the duty cycle: between 0 (always off) and 255 (always on).
</p>
<p class='vspace'></p><h4>Returns</h4>
<p>nothing
</p>
<p class='vspace'></p><h4>Notes and Known Issues</h4>
<p>The PWM outputs generated on pins 5 and 6 will have higher-than-expected duty cycles. This is because of interactions with the millis() and delay() functions, which share the same internal timer used to generate those PWM outputs. This will be noticed mostly on low duty-cycle settings (e.g 0 - 10) and may result in a value of 0 not fully turning off the output on pins 5 and 6.
</p>
<p class='vspace'></p><h4>Example</h4>
<p>Sets the output to the LED proportional to the value read from the potentiometer.
</p>
<p class='vspace'></p><pre>
int ledPin = 9; // LED connected to digital pin 9
int analogPin = 3; // potentiometer connected to analog pin 3
int val = 0; // variable to store the read value
void setup()
{
pinMode(ledPin, OUTPUT); // sets the pin as output
}
void loop()
{
val = analogRead(analogPin); // read the input pin
analogWrite(ledPin, val / 4); // analogRead values go from 0 to 1023, analogWrite values from 0 to 255
}
</pre>
<p class='vspace'></p><h4>See also</h4>
<ul><li><a class='wikilink' href='AnalogRead.html'>analogRead</a>()
</li><li><a class='wikilink' href='http://arduino.cc/en/Tutorial/PWM'>Tutorial: PWM</a>
</li></ul><p class='vspace'></p><p><a class='wikilink' href='index.html'>Reference Home</a>
</p>
<p class='vspace'></p><p><em>Corrections, suggestions, and new documentation should be posted to the <a class='urllink' href='http://arduino.cc/forum/index.php/board,23.0.html' rel='nofollow'>Forum</a>.</em>
</p>
<p class='vspace'></p><p>The text of the Arduino reference is licensed under a
<a class='urllink' href='http://creativecommons.org/licenses/by-sa/3.0/' rel='nofollow'>Creative Commons Attribution-ShareAlike 3.0 License</a>. Code samples in the reference are released into the public domain.
</p>
</div>
</div>
<!--PageFooterFmt-->
<div id="pagefooter">
&copy;Arduino |
<a href='#'>Edit Page</a> | <a href='#'>Page History</a> | <a href='#' target='_blank'>Printable View</a> | <a href='http://arduino.cc/en/Site/AllRecentChanges'>All Recent Site Changes</a>
</div>
<!--/PageFooterFmt-->
</div>
</body>
</html>

View File

@@ -0,0 +1,123 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>Arduino Reference - Arithmetic </title>
<link rel="shortcut icon" type="image/x-icon" href="http://arduino.cc/en/favicon.png">
<link rel='stylesheet' href='arduinoWideRender.css'
type='text/css' />
<!--HeaderText--><style type='text/css'><!--
ul, ol, pre, dl, p { margin-top:0px; margin-bottom:0px; }
code { white-space: nowrap; }
.vspace { margin-top:1.33em; }
.indent { margin-left:40px; }
.outdent { margin-left:40px; text-indent:-40px; }
a.createlinktext { text-decoration:none; border-bottom:1px dotted gray; }
a.createlink { text-decoration:none; position:relative; top:-0.5em;
font-weight:bold; font-size:smaller; border-bottom:none; }
img { border:0px; }
.editconflict { color:green;
font-style:italic; margin-top:1.33em; margin-bottom:1.33em; }
table.markup { border: 2px dotted #ccf; width:90%; }
td.markup1, td.markup2 { padding-left:10px; padding-right:10px; }
td.markup1 { border-bottom: 1px solid #ccf; }
div.faq { margin-left:2em; }
div.faq p.question { margin: 1em 0 0.75em -2em; font-weight:bold; }
div.faq hr { margin-left: -2em; }
.frame
{ border:1px solid #cccccc; padding:4px; background-color:#f9f9f9; }
.lfloat { float:left; margin-right:0.5em; }
.rfloat { float:right; margin-left:0.5em; }
a.varlink { text-decoration:none; }
--></style> <meta name='robots' content='index,follow' />
<meta name="verify-v1" content="TtxFIEJAB6zdJ509wLxjnapQzKAMNm9u0Wj4ho6wxIY=" />
</head>
<body>
<div id="page">
<!--PageHeaderFmt-->
<div id="pageheader">
<div class="title"><a href='http://arduino.cc/en'>Arduino</a></div>
</div>
<!--/PageHeaderFmt-->
<!--PageLeftFmt-->
<div id="pagenav">
<div id="navbar">
<p><a class='wikilink' href='http://arduino.cc/en/Main/Buy'>Buy</a>
<a class='wikilink' href='http://arduino.cc/en/Main/Software'>Download</a>
<a class='wikilink' href='Guide_index.html'>Getting Started</a>
<a class='wikilink' href='http://arduino.cc/en/Tutorial/HomePage'>Learning</a>
<a class='wikilink' href='index.html'>Reference</a>
<a class='wikilink' href='http://arduino.cc/en/Main/Hardware'>Hardware</a>
<a class='wikilink' href='FAQ.html'>FAQ</a>
</p>
<p class='vspace'></p>
</div>
</div>
<!--/PageLeftFmt-->
<div id="pagetext">
<!--PageText-->
<div id='wikitext'>
<p><strong>Reference</strong> &nbsp; <a class='wikilink' href='index.html'>Language</a> | <a class='wikilink' href='Libraries.html'>Libraries</a> | <a class='wikilink' href='Comparison.html'>Comparison</a> | <a class='wikilink' href='Changes.html'>Changes</a>
</p>
<p class='vspace'></p><h2>Addition, Subtraction, Multiplication, &amp; Division</h2>
<h4>Description</h4>
<p>These operators return the sum, difference, product, or quotient (respectively) of the two operands. The operation is conducted using the data type of the operands, so, for example, <code>9 / 4</code> gives <code>2</code> since 9 and 4 are ints. This also means that the operation can overflow if the result is larger than that which can be stored in the data type (e.g. adding 1 to an <a class='wikilink' href='Int.html'>int</a> with the value 32,767 gives -32,768). If the operands are of different types, the "larger" type is used for the calculation.
</p>
<p class='vspace'></p><p>If one of the numbers (operands) are of the type <strong>float</strong> or of type <strong>double</strong>, floating point math will be used for the calculation.
</p>
<p class='vspace'></p><h4>Examples</h4>
<pre>
y = y + 3;
x = x - 7;
i = j * 6;
r = r / 5;
</pre>
<p class='vspace'></p><h4>Syntax</h4>
<pre>
result = value1 + value2;
result = value1 - value2;
result = value1 * value2;
result = value1 / value2;
</pre>
<p class='vspace'></p><h4>Parameters:</h4>
<p>value1: any variable or constant
</p>
<p class='vspace'></p><p>value2: any variable or constant
</p>
<p class='vspace'></p><h4>Programming Tips:</h4>
<ul><li>Know that <a class='wikilink' href='IntegerConstants.html'>integer constants</a> default to <a class='wikilink' href='Int.html'>int</a>, so some constant calculations may overflow (e.g. 60 * 1000 will yield a negative result).
<p class='vspace'></p></li><li>Choose variable sizes that are large enough to hold the largest results from your calculations
<p class='vspace'></p></li><li>Know at what point your variable will "roll over" and also what happens in the other direction e.g. (0 - 1) OR (0 - - 32768)
<p class='vspace'></p></li><li>For math that requires fractions, use float variables, but be aware of their drawbacks: large size, slow computation speeds
<p class='vspace'></p></li><li>Use the cast operator e.g. (int)myFloat to convert one variable type to another on the fly.
</li></ul><p class='vspace'></p><p><a class='wikilink' href='index.html'>Reference Home</a>
</p>
<p class='vspace'></p><p><em>Corrections, suggestions, and new documentation should be posted to the <a class='urllink' href='http://arduino.cc/forum/index.php/board,23.0.html' rel='nofollow'>Forum</a>.</em>
</p>
<p class='vspace'></p><p>The text of the Arduino reference is licensed under a
<a class='urllink' href='http://creativecommons.org/licenses/by-sa/3.0/' rel='nofollow'>Creative Commons Attribution-ShareAlike 3.0 License</a>. Code samples in the reference are released into the public domain.
</p>
</div>
</div>
<!--PageFooterFmt-->
<div id="pagefooter">
&copy;Arduino |
<a href='#'>Edit Page</a> | <a href='#'>Page History</a> | <a href='#' target='_blank'>Printable View</a> | <a href='http://arduino.cc/en/Site/AllRecentChanges'>All Recent Site Changes</a>
</div>
<!--/PageFooterFmt-->
</div>
</body>
</html>

View File

@@ -0,0 +1,142 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>Arduino Reference - Array </title>
<link rel="shortcut icon" type="image/x-icon" href="http://arduino.cc/en/favicon.png">
<link rel='stylesheet' href='arduinoWideRender.css'
type='text/css' />
<!--HeaderText--><style type='text/css'><!--
ul, ol, pre, dl, p { margin-top:0px; margin-bottom:0px; }
code { white-space: nowrap; }
.vspace { margin-top:1.33em; }
.indent { margin-left:40px; }
.outdent { margin-left:40px; text-indent:-40px; }
a.createlinktext { text-decoration:none; border-bottom:1px dotted gray; }
a.createlink { text-decoration:none; position:relative; top:-0.5em;
font-weight:bold; font-size:smaller; border-bottom:none; }
img { border:0px; }
.editconflict { color:green;
font-style:italic; margin-top:1.33em; margin-bottom:1.33em; }
table.markup { border: 2px dotted #ccf; width:90%; }
td.markup1, td.markup2 { padding-left:10px; padding-right:10px; }
td.markup1 { border-bottom: 1px solid #ccf; }
div.faq { margin-left:2em; }
div.faq p.question { margin: 1em 0 0.75em -2em; font-weight:bold; }
div.faq hr { margin-left: -2em; }
.frame
{ border:1px solid #cccccc; padding:4px; background-color:#f9f9f9; }
.lfloat { float:left; margin-right:0.5em; }
.rfloat { float:right; margin-left:0.5em; }
a.varlink { text-decoration:none; }
--></style> <meta name='robots' content='index,follow' />
<meta name="verify-v1" content="TtxFIEJAB6zdJ509wLxjnapQzKAMNm9u0Wj4ho6wxIY=" />
</head>
<body>
<div id="page">
<!--PageHeaderFmt-->
<div id="pageheader">
<div class="title"><a href='http://arduino.cc/en'>Arduino</a></div>
</div>
<!--/PageHeaderFmt-->
<!--PageLeftFmt-->
<div id="pagenav">
<div id="navbar">
<p><a class='wikilink' href='http://arduino.cc/en/Main/Buy'>Buy</a>
<a class='wikilink' href='http://arduino.cc/en/Main/Software'>Download</a>
<a class='wikilink' href='Guide_index.html'>Getting Started</a>
<a class='wikilink' href='http://arduino.cc/en/Tutorial/HomePage'>Learning</a>
<a class='wikilink' href='index.html'>Reference</a>
<a class='wikilink' href='http://arduino.cc/en/Main/Hardware'>Hardware</a>
<a class='wikilink' href='FAQ.html'>FAQ</a>
</p>
<p class='vspace'></p>
</div>
</div>
<!--/PageLeftFmt-->
<div id="pagetext">
<!--PageText-->
<div id='wikitext'>
<p><strong>Reference</strong> &nbsp; <a class='wikilink' href='index.html'>Language</a> | <a class='wikilink' href='Libraries.html'>Libraries</a> | <a class='wikilink' href='Comparison.html'>Comparison</a> | <a class='wikilink' href='Changes.html'>Changes</a>
</p>
<p class='vspace'></p><h2>Arrays</h2>
<p>An array is a collection of variables that are accessed with an index number. Arrays in the C programming language, on which Arduino is based, can be complicated, but using simple arrays is relatively straightforward.
</p>
<p class='vspace'></p><h4>Creating (Declaring) an Array</h4>
<p>All of the methods below are valid ways to create (declare) an array.
</p>
<p class='vspace'></p><pre>
int myInts[6];
int myPins[] = {2, 4, 8, 3, 6};
int mySensVals[6] = {2, 4, -8, 3, 2};
char message[6] = "hello";
</pre>
<p class='vspace'></p><p>You can declare an array without initializing it as in myInts.<br /><br />In myPins we declare an array without explicitly choosing a size. The compiler counts the elements and creates an array of the appropriate size.
</p>
<p class='vspace'></p><p>Finally you can both initialize and size your array, as in mySensVals. Note that when declaring an array of type char, one more element than your initialization is required, to hold the required null character.
</p>
<p class='vspace'></p><h4>Accessing an Array</h4>
<p>Arrays are <strong>zero indexed</strong>, that is, referring to the array initialization above, the first element of the array is at index 0, hence<br /><br /><code>mySensVals[0] == 2, mySensVals[1] == 4,</code> and so forth.
</p>
<p class='vspace'></p><p>It also means that in an array with ten elements, index nine is the last element. Hence:
</p><pre>
int myArray[10]={9,3,2,4,3,2,7,8,9,11};
// myArray[9] contains 11
// myArray[10] is invalid and contains random information (other memory address)
</pre>
<p class='vspace'></p><p>For this reason you should be careful in accessing arrays. Accessing past the end of an array (using an index number greater than your declared array size - 1) is reading from memory that is in use for other purposes. Reading from these locations is probably not going to do much except yield invalid data. Writing to random memory locations is definitely a bad idea and can often lead to unhappy results such as crashes or program malfunction. This can also be a difficult bug to track down.
</p>
<p class='vspace'></p><p>Unlike BASIC or JAVA, the C compiler does no checking to see if array access is within legal bounds of the array size that you have declared.
</p>
<p class='vspace'></p><h4>To assign a value to an array:</h4>
<pre>
mySensVals[0] = 10;
</pre>
<p class='vspace'></p><h4>To retrieve a value from an array:</h4>
<p><code>x = mySensVals[4]</code>;
</p>
<p class='vspace'></p><h4>Arrays and FOR Loops</h4>
<p>Arrays are often manipulated inside <strong>for</strong> loops, where the loop counter is used as the index for each array element. For example, to print the elements of an array over the serial port, you could do something like this:
</p>
<p class='vspace'></p><pre>
int i;
for (i = 0; i &lt; 5; i = i + 1) {
Serial.println(myPins[i]);
}
</pre><h4>Example</h4>
<p>For a complete program that demonstrates the use of arrays, see the <a class='urllink' href='http://www.arduino.cc/en/Tutorial/KnightRider' rel='nofollow'>Knight Rider example</a> from the <a class='urllink' href='http://www.arduino.cc/en/Main/LearnArduino' rel='nofollow'>Tutorials</a>.
</p>
<p class='vspace'></p><h4>See also</h4>
<ul><li><a class='urllink' href='http://arduino.cc/en/Reference/VariableDeclaration' rel='nofollow'>Variable Declaration</a>
</li><li><a class='wikilink' href='PROGMEM.html'>PROGMEM</a>
</li></ul><p class='vspace'></p><p><a class='wikilink' href='index.html'>Reference Home</a>
</p>
<p class='vspace'></p><p><em>Corrections, suggestions, and new documentation should be posted to the <a class='urllink' href='http://arduino.cc/forum/index.php/board,23.0.html' rel='nofollow'>Forum</a>.</em>
</p>
<p class='vspace'></p><p>The text of the Arduino reference is licensed under a
<a class='urllink' href='http://creativecommons.org/licenses/by-sa/3.0/' rel='nofollow'>Creative Commons Attribution-ShareAlike 3.0 License</a>. Code samples in the reference are released into the public domain.
</p>
</div>
</div>
<!--PageFooterFmt-->
<div id="pagefooter">
&copy;Arduino |
<a href='#'>Edit Page</a> | <a href='#'>Page History</a> | <a href='#' target='_blank'>Printable View</a> | <a href='http://arduino.cc/en/Site/AllRecentChanges'>All Recent Site Changes</a>
</div>
<!--/PageFooterFmt-->
</div>
</body>
</html>

View File

@@ -0,0 +1,109 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>Arduino Reference - Assignment </title>
<link rel="shortcut icon" type="image/x-icon" href="http://arduino.cc/en/favicon.png">
<link rel='stylesheet' href='arduinoWideRender.css'
type='text/css' />
<!--HeaderText--><style type='text/css'><!--
ul, ol, pre, dl, p { margin-top:0px; margin-bottom:0px; }
code { white-space: nowrap; }
.vspace { margin-top:1.33em; }
.indent { margin-left:40px; }
.outdent { margin-left:40px; text-indent:-40px; }
a.createlinktext { text-decoration:none; border-bottom:1px dotted gray; }
a.createlink { text-decoration:none; position:relative; top:-0.5em;
font-weight:bold; font-size:smaller; border-bottom:none; }
img { border:0px; }
.editconflict { color:green;
font-style:italic; margin-top:1.33em; margin-bottom:1.33em; }
table.markup { border: 2px dotted #ccf; width:90%; }
td.markup1, td.markup2 { padding-left:10px; padding-right:10px; }
td.markup1 { border-bottom: 1px solid #ccf; }
div.faq { margin-left:2em; }
div.faq p.question { margin: 1em 0 0.75em -2em; font-weight:bold; }
div.faq hr { margin-left: -2em; }
.frame
{ border:1px solid #cccccc; padding:4px; background-color:#f9f9f9; }
.lfloat { float:left; margin-right:0.5em; }
.rfloat { float:right; margin-left:0.5em; }
a.varlink { text-decoration:none; }
--></style> <meta name='robots' content='index,follow' />
<meta name="verify-v1" content="TtxFIEJAB6zdJ509wLxjnapQzKAMNm9u0Wj4ho6wxIY=" />
</head>
<body>
<div id="page">
<!--PageHeaderFmt-->
<div id="pageheader">
<div class="title"><a href='http://arduino.cc/en'>Arduino</a></div>
</div>
<!--/PageHeaderFmt-->
<!--PageLeftFmt-->
<div id="pagenav">
<div id="navbar">
<p><a class='wikilink' href='http://arduino.cc/en/Main/Buy'>Buy</a>
<a class='wikilink' href='http://arduino.cc/en/Main/Software'>Download</a>
<a class='wikilink' href='Guide_index.html'>Getting Started</a>
<a class='wikilink' href='http://arduino.cc/en/Tutorial/HomePage'>Learning</a>
<a class='wikilink' href='index.html'>Reference</a>
<a class='wikilink' href='http://arduino.cc/en/Main/Hardware'>Hardware</a>
<a class='wikilink' href='FAQ.html'>FAQ</a>
</p>
<p class='vspace'></p>
</div>
</div>
<!--/PageLeftFmt-->
<div id="pagetext">
<!--PageText-->
<div id='wikitext'>
<p><strong>Reference</strong> &nbsp; <a class='wikilink' href='index.html'>Language</a> | <a class='wikilink' href='Libraries.html'>Libraries</a> | <a class='wikilink' href='Comparison.html'>Comparison</a> | <a class='wikilink' href='Changes.html'>Changes</a>
</p>
<p class='vspace'></p><h2>= assignment operator (single equal sign)</h2>
<p>Stores the value to the right of the equal sign in the variable to the left of the equal sign.
</p>
<p class='vspace'></p><p>The single equal sign in the C programming language is called the assignment operator. It has a different meaning than in algebra class where it indicated an equation or equality. The assignment operator tells the microcontroller to evaluate whatever value or expression is on the right side of the equal sign, and store it in the variable to the left of the equal sign.
</p>
<p class='vspace'></p><h4>Example</h4>
<pre> int sensVal; // declare an integer variable named sensVal
senVal = analogRead(0); // store the (digitized) input voltage at analog pin 0 in <span class='wikiword'>SensVal</span>
</pre>
<p class='vspace'></p><h4>Programming Tips</h4>
<p>The variable on the left side of the assignment operator ( = sign ) needs to be able to hold the value stored in it. If it is not large enough to hold a value, the value stored in the variable will be incorrect.
</p>
<p class='vspace'></p><p>Don't confuse the assignment operator [ = ] (single equal sign) with the comparison operator [ == ] (double equal signs), which evaluates whether two expressions are equal.
</p>
<p class='vspace'></p><h4>See Also</h4>
<ul><li><a class='wikilink' href='If.html'>if (comparison operators)</a>
</li><li><a class='wikilink' href='Char.html'>char</a>
</li><li><a class='wikilink' href='Int.html'>int</a>
</li><li><a class='wikilink' href='Long.html'>long</a>
</li></ul><p><a class='wikilink' href='index.html'>Reference Home</a>
</p>
<p class='vspace'></p><p><em>Corrections, suggestions, and new documentation should be posted to the <a class='urllink' href='http://arduino.cc/forum/index.php/board,23.0.html' rel='nofollow'>Forum</a>.</em>
</p>
<p class='vspace'></p><p>The text of the Arduino reference is licensed under a
<a class='urllink' href='http://creativecommons.org/licenses/by-sa/3.0/' rel='nofollow'>Creative Commons Attribution-ShareAlike 3.0 License</a>. Code samples in the reference are released into the public domain.
</p>
</div>
</div>
<!--PageFooterFmt-->
<div id="pagefooter">
&copy;Arduino |
<a href='#'>Edit Page</a> | <a href='#'>Page History</a> | <a href='#' target='_blank'>Printable View</a> | <a href='http://arduino.cc/en/Site/AllRecentChanges'>All Recent Site Changes</a>
</div>
<!--/PageFooterFmt-->
</div>
</body>
</html>

View File

@@ -0,0 +1,138 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>Arduino Reference - AttachInterrupt </title>
<link rel="shortcut icon" type="image/x-icon" href="http://arduino.cc/en/favicon.png">
<link rel='stylesheet' href='arduinoWideRender.css'
type='text/css' />
<!--HeaderText--><style type='text/css'><!--
ul, ol, pre, dl, p { margin-top:0px; margin-bottom:0px; }
code { white-space: nowrap; }
.vspace { margin-top:1.33em; }
.indent { margin-left:40px; }
.outdent { margin-left:40px; text-indent:-40px; }
a.createlinktext { text-decoration:none; border-bottom:1px dotted gray; }
a.createlink { text-decoration:none; position:relative; top:-0.5em;
font-weight:bold; font-size:smaller; border-bottom:none; }
img { border:0px; }
.editconflict { color:green;
font-style:italic; margin-top:1.33em; margin-bottom:1.33em; }
table.markup { border: 2px dotted #ccf; width:90%; }
td.markup1, td.markup2 { padding-left:10px; padding-right:10px; }
td.markup1 { border-bottom: 1px solid #ccf; }
div.faq { margin-left:2em; }
div.faq p.question { margin: 1em 0 0.75em -2em; font-weight:bold; }
div.faq hr { margin-left: -2em; }
.frame
{ border:1px solid #cccccc; padding:4px; background-color:#f9f9f9; }
.lfloat { float:left; margin-right:0.5em; }
.rfloat { float:right; margin-left:0.5em; }
a.varlink { text-decoration:none; }
--></style> <meta name='robots' content='index,follow' />
<meta name="verify-v1" content="TtxFIEJAB6zdJ509wLxjnapQzKAMNm9u0Wj4ho6wxIY=" />
</head>
<body>
<div id="page">
<!--PageHeaderFmt-->
<div id="pageheader">
<div class="title"><a href='http://arduino.cc/en'>Arduino</a></div>
</div>
<!--/PageHeaderFmt-->
<!--PageLeftFmt-->
<div id="pagenav">
<div id="navbar">
<p><a class='wikilink' href='http://arduino.cc/en/Main/Buy'>Buy</a>
<a class='wikilink' href='http://arduino.cc/en/Main/Software'>Download</a>
<a class='wikilink' href='Guide_index.html'>Getting Started</a>
<a class='wikilink' href='http://arduino.cc/en/Tutorial/HomePage'>Learning</a>
<a class='wikilink' href='index.html'>Reference</a>
<a class='wikilink' href='http://arduino.cc/en/Main/Hardware'>Hardware</a>
<a class='wikilink' href='FAQ.html'>FAQ</a>
</p>
<p class='vspace'></p>
</div>
</div>
<!--/PageLeftFmt-->
<div id="pagetext">
<!--PageText-->
<div id='wikitext'>
<p><strong>Reference</strong> &nbsp; <a class='wikilink' href='index.html'>Language</a> | <a class='wikilink' href='Libraries.html'>Libraries</a> | <a class='wikilink' href='Comparison.html'>Comparison</a> | <a class='wikilink' href='Changes.html'>Changes</a>
</p>
<p class='vspace'></p><h2>attachInterrupt(interrupt, function, mode)</h2>
<p class='vspace'></p><h4>Description</h4>
<p>Specifies a function to call when an external interrupt occurs. Replaces any previous function that was attached to the interrupt. Most Arduino boards have two external interrupts: numbers 0 (on digital pin 2) and 1 (on digital pin 3). The Arduino Mega has an additional four: numbers 2 (pin 21), 3 (pin 20), 4 (pin 19), and 5 (pin 18).
</p>
<p class='vspace'></p><h4>Parameters</h4>
<p><strong>interrupt</strong>: the number of the interrupt (<em>int</em>)
</p>
<p class='vspace'></p><p><strong>function</strong>: the function to call when the interrupt occurs; this function must take no parameters and return nothing. This function is sometimes referred to as an <em>interrupt service routine.</em>
</p>
<p class='vspace'></p><p><strong>mode</strong> defines when the interrupt should be triggered. Four contstants are predefined as valid values:
</p><ul><li><strong>LOW</strong> to trigger the interrupt whenever the pin is low,
</li><li><strong>CHANGE</strong> to trigger the interrupt whenever the pin changes value
</li><li><strong>RISING</strong> to trigger when the pin goes from low to high,
</li><li><strong>FALLING</strong> for when the pin goes from high to low.
</li></ul><p class='vspace'></p><h4>Returns</h4>
<p>none
</p>
<p class='vspace'></p><h4>Note</h4>
<p><em>Inside the attached function, delay() won't work and the value returned by millis() will not increment. Serial data received while in the function may be lost. You should declare as volatile any variables that you modify within the attached function.</em>
</p>
<p class='vspace'></p><h4>Using Interrupts</h4>
<p>Interrupts are useful for making things happen automatically in microcontroller programs, and can help solve timing problems. A good task for using an interrupt might be reading a rotary encoder, monitoring user input.
</p>
<p class='vspace'></p><p>If you wanted to insure that a program always caught the pulses from a rotary encoder, never missing a pulse, it would make it very tricky to write a program to do anything else, because the program would need to constantly poll the sensor lines for the encoder, in order to catch pulses when they occurred. Other sensors have a similar interface dynamic too, such as trying to read a sound sensor that is trying to catch a click, or an infrared slot sensor (photo-interrupter) trying to catch a coin drop. In all of these situations, using an interrupt can free the microcontroller to get some other work done while not missing the doorbell.
</p>
<p class='vspace'></p><h4>Example</h4>
<pre>int pin = 13;
volatile int state = LOW;
void setup()
{
pinMode(pin, OUTPUT);
attachInterrupt(0, blink, CHANGE);
}
void loop()
{
digitalWrite(pin, state);
}
void blink()
{
state = !state;
}
</pre>
<p class='vspace'></p><h4>See also</h4>
<ul><li><a class='wikilink' href='DetachInterrupt.html'>detachInterrupt</a>
</li></ul><p><a class='wikilink' href='index.html'>Reference Home</a>
</p>
<p class='vspace'></p><p><em>Corrections, suggestions, and new documentation should be posted to the <a class='urllink' href='http://arduino.cc/forum/index.php/board,23.0.html' rel='nofollow'>Forum</a>.</em>
</p>
<p class='vspace'></p><p>The text of the Arduino reference is licensed under a
<a class='urllink' href='http://creativecommons.org/licenses/by-sa/3.0/' rel='nofollow'>Creative Commons Attribution-ShareAlike 3.0 License</a>. Code samples in the reference are released into the public domain.
</p>
</div>
</div>
<!--PageFooterFmt-->
<div id="pagefooter">
&copy;Arduino |
<a href='#'>Edit Page</a> | <a href='#'>Page History</a> | <a href='#' target='_blank'>Printable View</a> | <a href='http://arduino.cc/en/Site/AllRecentChanges'>All Recent Site Changes</a>
</div>
<!--/PageFooterFmt-->
</div>
</body>
</html>

View File

@@ -0,0 +1,108 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>Arduino Reference - Bit </title>
<link rel="shortcut icon" type="image/x-icon" href="http://arduino.cc/en/favicon.png">
<link rel='stylesheet' href='arduinoWideRender.css'
type='text/css' />
<!--HeaderText--><style type='text/css'><!--
ul, ol, pre, dl, p { margin-top:0px; margin-bottom:0px; }
code { white-space: nowrap; }
.vspace { margin-top:1.33em; }
.indent { margin-left:40px; }
.outdent { margin-left:40px; text-indent:-40px; }
a.createlinktext { text-decoration:none; border-bottom:1px dotted gray; }
a.createlink { text-decoration:none; position:relative; top:-0.5em;
font-weight:bold; font-size:smaller; border-bottom:none; }
img { border:0px; }
.editconflict { color:green;
font-style:italic; margin-top:1.33em; margin-bottom:1.33em; }
table.markup { border: 2px dotted #ccf; width:90%; }
td.markup1, td.markup2 { padding-left:10px; padding-right:10px; }
td.markup1 { border-bottom: 1px solid #ccf; }
div.faq { margin-left:2em; }
div.faq p.question { margin: 1em 0 0.75em -2em; font-weight:bold; }
div.faq hr { margin-left: -2em; }
.frame
{ border:1px solid #cccccc; padding:4px; background-color:#f9f9f9; }
.lfloat { float:left; margin-right:0.5em; }
.rfloat { float:right; margin-left:0.5em; }
a.varlink { text-decoration:none; }
--></style> <meta name='robots' content='index,follow' />
<meta name="verify-v1" content="TtxFIEJAB6zdJ509wLxjnapQzKAMNm9u0Wj4ho6wxIY=" />
</head>
<body>
<div id="page">
<!--PageHeaderFmt-->
<div id="pageheader">
<div class="title"><a href='http://arduino.cc/en'>Arduino</a></div>
</div>
<!--/PageHeaderFmt-->
<!--PageLeftFmt-->
<div id="pagenav">
<div id="navbar">
<p><a class='wikilink' href='http://arduino.cc/en/Main/Buy'>Buy</a>
<a class='wikilink' href='http://arduino.cc/en/Main/Software'>Download</a>
<a class='wikilink' href='Guide_index.html'>Getting Started</a>
<a class='wikilink' href='http://arduino.cc/en/Tutorial/HomePage'>Learning</a>
<a class='wikilink' href='index.html'>Reference</a>
<a class='wikilink' href='http://arduino.cc/en/Main/Hardware'>Hardware</a>
<a class='wikilink' href='FAQ.html'>FAQ</a>
</p>
<p class='vspace'></p>
</div>
</div>
<!--/PageLeftFmt-->
<div id="pagetext">
<!--PageText-->
<div id='wikitext'>
<p><strong>Reference</strong> &nbsp; <a class='wikilink' href='index.html'>Language</a> | <a class='wikilink' href='Libraries.html'>Libraries</a> | <a class='wikilink' href='Comparison.html'>Comparison</a> | <a class='wikilink' href='Changes.html'>Changes</a>
</p>
<p class='vspace'></p><h2>bit()</h2>
<h4>Description</h4>
<p>Computes the value of the specified bit (bit 0 is 1, bit 1 is 2, bit 2 is 4, etc.).
</p>
<p class='vspace'></p><h4>Syntax</h4>
<p>bit(n)
</p>
<p class='vspace'></p><h4>Parameters</h4>
<p>n: the bit whose value to compute
</p>
<p class='vspace'></p><h4>Returns</h4>
<p>the value of the bit
</p>
<p class='vspace'></p><h4>See also</h4>
<ul><li><a class='wikilink' href='BitRead.html'>bitRead</a>()
</li><li><a class='wikilink' href='BitWrite.html'>bitWrite</a>()
</li><li><a class='wikilink' href='BitSet.html'>bitSet</a>()
</li><li><a class='wikilink' href='BitClear.html'>bitClear</a>()
</li></ul><p><a class='wikilink' href='index.html'>Reference Home</a>
</p>
<p class='vspace'></p><p><em>Corrections, suggestions, and new documentation should be posted to the <a class='urllink' href='http://arduino.cc/forum/index.php/board,23.0.html' rel='nofollow'>Forum</a>.</em>
</p>
<p class='vspace'></p><p>The text of the Arduino reference is licensed under a
<a class='urllink' href='http://creativecommons.org/licenses/by-sa/3.0/' rel='nofollow'>Creative Commons Attribution-ShareAlike 3.0 License</a>. Code samples in the reference are released into the public domain.
</p>
</div>
</div>
<!--PageFooterFmt-->
<div id="pagefooter">
&copy;Arduino |
<a href='#'>Edit Page</a> | <a href='#'>Page History</a> | <a href='#' target='_blank'>Printable View</a> | <a href='http://arduino.cc/en/Site/AllRecentChanges'>All Recent Site Changes</a>
</div>
<!--/PageFooterFmt-->
</div>
</body>
</html>

View File

@@ -0,0 +1,110 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>Arduino Reference - BitClear </title>
<link rel="shortcut icon" type="image/x-icon" href="http://arduino.cc/en/favicon.png">
<link rel='stylesheet' href='arduinoWideRender.css'
type='text/css' />
<!--HeaderText--><style type='text/css'><!--
ul, ol, pre, dl, p { margin-top:0px; margin-bottom:0px; }
code { white-space: nowrap; }
.vspace { margin-top:1.33em; }
.indent { margin-left:40px; }
.outdent { margin-left:40px; text-indent:-40px; }
a.createlinktext { text-decoration:none; border-bottom:1px dotted gray; }
a.createlink { text-decoration:none; position:relative; top:-0.5em;
font-weight:bold; font-size:smaller; border-bottom:none; }
img { border:0px; }
.editconflict { color:green;
font-style:italic; margin-top:1.33em; margin-bottom:1.33em; }
table.markup { border: 2px dotted #ccf; width:90%; }
td.markup1, td.markup2 { padding-left:10px; padding-right:10px; }
td.markup1 { border-bottom: 1px solid #ccf; }
div.faq { margin-left:2em; }
div.faq p.question { margin: 1em 0 0.75em -2em; font-weight:bold; }
div.faq hr { margin-left: -2em; }
.frame
{ border:1px solid #cccccc; padding:4px; background-color:#f9f9f9; }
.lfloat { float:left; margin-right:0.5em; }
.rfloat { float:right; margin-left:0.5em; }
a.varlink { text-decoration:none; }
--></style> <meta name='robots' content='index,follow' />
<meta name="verify-v1" content="TtxFIEJAB6zdJ509wLxjnapQzKAMNm9u0Wj4ho6wxIY=" />
</head>
<body>
<div id="page">
<!--PageHeaderFmt-->
<div id="pageheader">
<div class="title"><a href='http://arduino.cc/en'>Arduino</a></div>
</div>
<!--/PageHeaderFmt-->
<!--PageLeftFmt-->
<div id="pagenav">
<div id="navbar">
<p><a class='wikilink' href='http://arduino.cc/en/Main/Buy'>Buy</a>
<a class='wikilink' href='http://arduino.cc/en/Main/Software'>Download</a>
<a class='wikilink' href='Guide_index.html'>Getting Started</a>
<a class='wikilink' href='http://arduino.cc/en/Tutorial/HomePage'>Learning</a>
<a class='wikilink' href='index.html'>Reference</a>
<a class='wikilink' href='http://arduino.cc/en/Main/Hardware'>Hardware</a>
<a class='wikilink' href='FAQ.html'>FAQ</a>
</p>
<p class='vspace'></p>
</div>
</div>
<!--/PageLeftFmt-->
<div id="pagetext">
<!--PageText-->
<div id='wikitext'>
<p><strong>Reference</strong> &nbsp; <a class='wikilink' href='index.html'>Language</a> | <a class='wikilink' href='Libraries.html'>Libraries</a> | <a class='wikilink' href='Comparison.html'>Comparison</a> | <a class='wikilink' href='Changes.html'>Changes</a>
</p>
<p class='vspace'></p><h2>bitClear()</h2>
<h4>Description</h4>
<p>Clears (writes a 0 to) a bit of a numeric variable.
</p>
<p class='vspace'></p><h4>Syntax</h4>
<p>bitClear(x, n)
</p>
<p class='vspace'></p><h4>Parameters</h4>
<p>x: the numeric variable whose bit to clear
</p>
<p class='vspace'></p><p>n: which bit to clear, starting at 0 for the least-significant (rightmost) bit
</p>
<p class='vspace'></p><h4>Returns</h4>
<p>none
</p>
<p class='vspace'></p><h4>See also</h4>
<ul><li><a class='wikilink' href='Bit.html'>bit</a>()
</li><li><a class='wikilink' href='BitRead.html'>bitRead</a>()
</li><li><a class='wikilink' href='BitWrite.html'>bitWrite</a>()
</li><li><a class='wikilink' href='BitSet.html'>bitSet</a>()
</li></ul><p class='vspace'></p><p><a class='wikilink' href='index.html'>Reference Home</a>
</p>
<p class='vspace'></p><p><em>Corrections, suggestions, and new documentation should be posted to the <a class='urllink' href='http://arduino.cc/forum/index.php/board,23.0.html' rel='nofollow'>Forum</a>.</em>
</p>
<p class='vspace'></p><p>The text of the Arduino reference is licensed under a
<a class='urllink' href='http://creativecommons.org/licenses/by-sa/3.0/' rel='nofollow'>Creative Commons Attribution-ShareAlike 3.0 License</a>. Code samples in the reference are released into the public domain.
</p>
</div>
</div>
<!--PageFooterFmt-->
<div id="pagefooter">
&copy;Arduino |
<a href='#'>Edit Page</a> | <a href='#'>Page History</a> | <a href='#' target='_blank'>Printable View</a> | <a href='http://arduino.cc/en/Site/AllRecentChanges'>All Recent Site Changes</a>
</div>
<!--/PageFooterFmt-->
</div>
</body>
</html>

View File

@@ -0,0 +1,110 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>Arduino Reference - BitRead </title>
<link rel="shortcut icon" type="image/x-icon" href="http://arduino.cc/en/favicon.png">
<link rel='stylesheet' href='arduinoWideRender.css'
type='text/css' />
<!--HeaderText--><style type='text/css'><!--
ul, ol, pre, dl, p { margin-top:0px; margin-bottom:0px; }
code { white-space: nowrap; }
.vspace { margin-top:1.33em; }
.indent { margin-left:40px; }
.outdent { margin-left:40px; text-indent:-40px; }
a.createlinktext { text-decoration:none; border-bottom:1px dotted gray; }
a.createlink { text-decoration:none; position:relative; top:-0.5em;
font-weight:bold; font-size:smaller; border-bottom:none; }
img { border:0px; }
.editconflict { color:green;
font-style:italic; margin-top:1.33em; margin-bottom:1.33em; }
table.markup { border: 2px dotted #ccf; width:90%; }
td.markup1, td.markup2 { padding-left:10px; padding-right:10px; }
td.markup1 { border-bottom: 1px solid #ccf; }
div.faq { margin-left:2em; }
div.faq p.question { margin: 1em 0 0.75em -2em; font-weight:bold; }
div.faq hr { margin-left: -2em; }
.frame
{ border:1px solid #cccccc; padding:4px; background-color:#f9f9f9; }
.lfloat { float:left; margin-right:0.5em; }
.rfloat { float:right; margin-left:0.5em; }
a.varlink { text-decoration:none; }
--></style> <meta name='robots' content='index,follow' />
<meta name="verify-v1" content="TtxFIEJAB6zdJ509wLxjnapQzKAMNm9u0Wj4ho6wxIY=" />
</head>
<body>
<div id="page">
<!--PageHeaderFmt-->
<div id="pageheader">
<div class="title"><a href='http://arduino.cc/en'>Arduino</a></div>
</div>
<!--/PageHeaderFmt-->
<!--PageLeftFmt-->
<div id="pagenav">
<div id="navbar">
<p><a class='wikilink' href='http://arduino.cc/en/Main/Buy'>Buy</a>
<a class='wikilink' href='http://arduino.cc/en/Main/Software'>Download</a>
<a class='wikilink' href='Guide_index.html'>Getting Started</a>
<a class='wikilink' href='http://arduino.cc/en/Tutorial/HomePage'>Learning</a>
<a class='wikilink' href='index.html'>Reference</a>
<a class='wikilink' href='http://arduino.cc/en/Main/Hardware'>Hardware</a>
<a class='wikilink' href='FAQ.html'>FAQ</a>
</p>
<p class='vspace'></p>
</div>
</div>
<!--/PageLeftFmt-->
<div id="pagetext">
<!--PageText-->
<div id='wikitext'>
<p><strong>Reference</strong> &nbsp; <a class='wikilink' href='index.html'>Language</a> | <a class='wikilink' href='Libraries.html'>Libraries</a> | <a class='wikilink' href='Comparison.html'>Comparison</a> | <a class='wikilink' href='Changes.html'>Changes</a>
</p>
<p class='vspace'></p><h2>bitRead()</h2>
<h4>Description</h4>
<p>Reads a bit of a number.
</p>
<p class='vspace'></p><h4>Syntax</h4>
<p>bitRead(x, n)
</p>
<p class='vspace'></p><h4>Parameters</h4>
<p>x: the number from which to read
</p>
<p class='vspace'></p><p>n: which bit to read, starting at 0 for the least-significant (rightmost) bit
</p>
<p class='vspace'></p><h4>Returns</h4>
<p>the value of the bit (0 or 1).
</p>
<p class='vspace'></p><h4>See also</h4>
<ul><li><a class='wikilink' href='Bit.html'>bit</a>()
</li><li><a class='wikilink' href='BitWrite.html'>bitWrite</a>()
</li><li><a class='wikilink' href='BitSet.html'>bitSet</a>()
</li><li><a class='wikilink' href='BitClear.html'>bitClear</a>()
</li></ul><p><a class='wikilink' href='index.html'>Reference Home</a>
</p>
<p class='vspace'></p><p><em>Corrections, suggestions, and new documentation should be posted to the <a class='urllink' href='http://arduino.cc/forum/index.php/board,23.0.html' rel='nofollow'>Forum</a>.</em>
</p>
<p class='vspace'></p><p>The text of the Arduino reference is licensed under a
<a class='urllink' href='http://creativecommons.org/licenses/by-sa/3.0/' rel='nofollow'>Creative Commons Attribution-ShareAlike 3.0 License</a>. Code samples in the reference are released into the public domain.
</p>
</div>
</div>
<!--PageFooterFmt-->
<div id="pagefooter">
&copy;Arduino |
<a href='#'>Edit Page</a> | <a href='#'>Page History</a> | <a href='#' target='_blank'>Printable View</a> | <a href='http://arduino.cc/en/Site/AllRecentChanges'>All Recent Site Changes</a>
</div>
<!--/PageFooterFmt-->
</div>
</body>
</html>

View File

@@ -0,0 +1,110 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>Arduino Reference - BitSet </title>
<link rel="shortcut icon" type="image/x-icon" href="http://arduino.cc/en/favicon.png">
<link rel='stylesheet' href='arduinoWideRender.css'
type='text/css' />
<!--HeaderText--><style type='text/css'><!--
ul, ol, pre, dl, p { margin-top:0px; margin-bottom:0px; }
code { white-space: nowrap; }
.vspace { margin-top:1.33em; }
.indent { margin-left:40px; }
.outdent { margin-left:40px; text-indent:-40px; }
a.createlinktext { text-decoration:none; border-bottom:1px dotted gray; }
a.createlink { text-decoration:none; position:relative; top:-0.5em;
font-weight:bold; font-size:smaller; border-bottom:none; }
img { border:0px; }
.editconflict { color:green;
font-style:italic; margin-top:1.33em; margin-bottom:1.33em; }
table.markup { border: 2px dotted #ccf; width:90%; }
td.markup1, td.markup2 { padding-left:10px; padding-right:10px; }
td.markup1 { border-bottom: 1px solid #ccf; }
div.faq { margin-left:2em; }
div.faq p.question { margin: 1em 0 0.75em -2em; font-weight:bold; }
div.faq hr { margin-left: -2em; }
.frame
{ border:1px solid #cccccc; padding:4px; background-color:#f9f9f9; }
.lfloat { float:left; margin-right:0.5em; }
.rfloat { float:right; margin-left:0.5em; }
a.varlink { text-decoration:none; }
--></style> <meta name='robots' content='index,follow' />
<meta name="verify-v1" content="TtxFIEJAB6zdJ509wLxjnapQzKAMNm9u0Wj4ho6wxIY=" />
</head>
<body>
<div id="page">
<!--PageHeaderFmt-->
<div id="pageheader">
<div class="title"><a href='http://arduino.cc/en'>Arduino</a></div>
</div>
<!--/PageHeaderFmt-->
<!--PageLeftFmt-->
<div id="pagenav">
<div id="navbar">
<p><a class='wikilink' href='http://arduino.cc/en/Main/Buy'>Buy</a>
<a class='wikilink' href='http://arduino.cc/en/Main/Software'>Download</a>
<a class='wikilink' href='Guide_index.html'>Getting Started</a>
<a class='wikilink' href='http://arduino.cc/en/Tutorial/HomePage'>Learning</a>
<a class='wikilink' href='index.html'>Reference</a>
<a class='wikilink' href='http://arduino.cc/en/Main/Hardware'>Hardware</a>
<a class='wikilink' href='FAQ.html'>FAQ</a>
</p>
<p class='vspace'></p>
</div>
</div>
<!--/PageLeftFmt-->
<div id="pagetext">
<!--PageText-->
<div id='wikitext'>
<p><strong>Reference</strong> &nbsp; <a class='wikilink' href='index.html'>Language</a> | <a class='wikilink' href='Libraries.html'>Libraries</a> | <a class='wikilink' href='Comparison.html'>Comparison</a> | <a class='wikilink' href='Changes.html'>Changes</a>
</p>
<p class='vspace'></p><h2>bitSet()</h2>
<h4>Description</h4>
<p>Sets (writes a 1 to) a bit of a numeric variable.
</p>
<p class='vspace'></p><h4>Syntax</h4>
<p>bitSet(x, n)
</p>
<p class='vspace'></p><h4>Parameters</h4>
<p>x: the numeric variable whose bit to set
</p>
<p class='vspace'></p><p>n: which bit to set, starting at 0 for the least-significant (rightmost) bit
</p>
<p class='vspace'></p><h4>Returns</h4>
<p>none
</p>
<p class='vspace'></p><h4>See also</h4>
<ul><li><a class='wikilink' href='Bit.html'>bit</a>()
</li><li><a class='wikilink' href='BitRead.html'>bitRead</a>()
</li><li><a class='wikilink' href='BitWrite.html'>bitWrite</a>()
</li><li><a class='wikilink' href='BitClear.html'>bitClear</a>()
</li></ul><p class='vspace'></p><p><a class='wikilink' href='index.html'>Reference Home</a>
</p>
<p class='vspace'></p><p><em>Corrections, suggestions, and new documentation should be posted to the <a class='urllink' href='http://arduino.cc/forum/index.php/board,23.0.html' rel='nofollow'>Forum</a>.</em>
</p>
<p class='vspace'></p><p>The text of the Arduino reference is licensed under a
<a class='urllink' href='http://creativecommons.org/licenses/by-sa/3.0/' rel='nofollow'>Creative Commons Attribution-ShareAlike 3.0 License</a>. Code samples in the reference are released into the public domain.
</p>
</div>
</div>
<!--PageFooterFmt-->
<div id="pagefooter">
&copy;Arduino |
<a href='#'>Edit Page</a> | <a href='#'>Page History</a> | <a href='#' target='_blank'>Printable View</a> | <a href='http://arduino.cc/en/Site/AllRecentChanges'>All Recent Site Changes</a>
</div>
<!--/PageFooterFmt-->
</div>
</body>
</html>

View File

@@ -0,0 +1,112 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>Arduino Reference - BitWrite </title>
<link rel="shortcut icon" type="image/x-icon" href="http://arduino.cc/en/favicon.png">
<link rel='stylesheet' href='arduinoWideRender.css'
type='text/css' />
<!--HeaderText--><style type='text/css'><!--
ul, ol, pre, dl, p { margin-top:0px; margin-bottom:0px; }
code { white-space: nowrap; }
.vspace { margin-top:1.33em; }
.indent { margin-left:40px; }
.outdent { margin-left:40px; text-indent:-40px; }
a.createlinktext { text-decoration:none; border-bottom:1px dotted gray; }
a.createlink { text-decoration:none; position:relative; top:-0.5em;
font-weight:bold; font-size:smaller; border-bottom:none; }
img { border:0px; }
.editconflict { color:green;
font-style:italic; margin-top:1.33em; margin-bottom:1.33em; }
table.markup { border: 2px dotted #ccf; width:90%; }
td.markup1, td.markup2 { padding-left:10px; padding-right:10px; }
td.markup1 { border-bottom: 1px solid #ccf; }
div.faq { margin-left:2em; }
div.faq p.question { margin: 1em 0 0.75em -2em; font-weight:bold; }
div.faq hr { margin-left: -2em; }
.frame
{ border:1px solid #cccccc; padding:4px; background-color:#f9f9f9; }
.lfloat { float:left; margin-right:0.5em; }
.rfloat { float:right; margin-left:0.5em; }
a.varlink { text-decoration:none; }
--></style> <meta name='robots' content='index,follow' />
<meta name="verify-v1" content="TtxFIEJAB6zdJ509wLxjnapQzKAMNm9u0Wj4ho6wxIY=" />
</head>
<body>
<div id="page">
<!--PageHeaderFmt-->
<div id="pageheader">
<div class="title"><a href='http://arduino.cc/en'>Arduino</a></div>
</div>
<!--/PageHeaderFmt-->
<!--PageLeftFmt-->
<div id="pagenav">
<div id="navbar">
<p><a class='wikilink' href='http://arduino.cc/en/Main/Buy'>Buy</a>
<a class='wikilink' href='http://arduino.cc/en/Main/Software'>Download</a>
<a class='wikilink' href='Guide_index.html'>Getting Started</a>
<a class='wikilink' href='http://arduino.cc/en/Tutorial/HomePage'>Learning</a>
<a class='wikilink' href='index.html'>Reference</a>
<a class='wikilink' href='http://arduino.cc/en/Main/Hardware'>Hardware</a>
<a class='wikilink' href='FAQ.html'>FAQ</a>
</p>
<p class='vspace'></p>
</div>
</div>
<!--/PageLeftFmt-->
<div id="pagetext">
<!--PageText-->
<div id='wikitext'>
<p><strong>Reference</strong> &nbsp; <a class='wikilink' href='index.html'>Language</a> | <a class='wikilink' href='Libraries.html'>Libraries</a> | <a class='wikilink' href='Comparison.html'>Comparison</a> | <a class='wikilink' href='Changes.html'>Changes</a>
</p>
<p class='vspace'></p><h2>bitWrite()</h2>
<h4>Description</h4>
<p>Writes a bit of a numeric variable.
</p>
<p class='vspace'></p><h4>Syntax</h4>
<p>bitWrite(x, n, b)
</p>
<p class='vspace'></p><h4>Parameters</h4>
<p>x: the numeric variable to which to write
</p>
<p class='vspace'></p><p>n: which bit of the number to write, starting at 0 for the least-significant (rightmost) bit
</p>
<p class='vspace'></p><p>b: the value to write to the bit (0 or 1)
</p>
<p class='vspace'></p><h4>Returns</h4>
<p>none
</p>
<p class='vspace'></p><h4>See also</h4>
<ul><li><a class='wikilink' href='Bit.html'>bit</a>()
</li><li><a class='wikilink' href='BitRead.html'>bitRead</a>()
</li><li><a class='wikilink' href='BitSet.html'>bitSet</a>()
</li><li><a class='wikilink' href='BitClear.html'>bitClear</a>()
</li></ul><p class='vspace'></p><p><a class='wikilink' href='index.html'>Reference Home</a>
</p>
<p class='vspace'></p><p><em>Corrections, suggestions, and new documentation should be posted to the <a class='urllink' href='http://arduino.cc/forum/index.php/board,23.0.html' rel='nofollow'>Forum</a>.</em>
</p>
<p class='vspace'></p><p>The text of the Arduino reference is licensed under a
<a class='urllink' href='http://creativecommons.org/licenses/by-sa/3.0/' rel='nofollow'>Creative Commons Attribution-ShareAlike 3.0 License</a>. Code samples in the reference are released into the public domain.
</p>
</div>
</div>
<!--PageFooterFmt-->
<div id="pagefooter">
&copy;Arduino |
<a href='#'>Edit Page</a> | <a href='#'>Page History</a> | <a href='#' target='_blank'>Printable View</a> | <a href='http://arduino.cc/en/Site/AllRecentChanges'>All Recent Site Changes</a>
</div>
<!--/PageFooterFmt-->
</div>
</body>
</html>

View File

@@ -0,0 +1,142 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>Arduino Reference - Bitshift </title>
<link rel="shortcut icon" type="image/x-icon" href="http://arduino.cc/en/favicon.png">
<link rel='stylesheet' href='arduinoWideRender.css'
type='text/css' />
<!--HeaderText--><style type='text/css'><!--
ul, ol, pre, dl, p { margin-top:0px; margin-bottom:0px; }
code { white-space: nowrap; }
.vspace { margin-top:1.33em; }
.indent { margin-left:40px; }
.outdent { margin-left:40px; text-indent:-40px; }
a.createlinktext { text-decoration:none; border-bottom:1px dotted gray; }
a.createlink { text-decoration:none; position:relative; top:-0.5em;
font-weight:bold; font-size:smaller; border-bottom:none; }
img { border:0px; }
.editconflict { color:green;
font-style:italic; margin-top:1.33em; margin-bottom:1.33em; }
table.markup { border: 2px dotted #ccf; width:90%; }
td.markup1, td.markup2 { padding-left:10px; padding-right:10px; }
td.markup1 { border-bottom: 1px solid #ccf; }
div.faq { margin-left:2em; }
div.faq p.question { margin: 1em 0 0.75em -2em; font-weight:bold; }
div.faq hr { margin-left: -2em; }
.frame
{ border:1px solid #cccccc; padding:4px; background-color:#f9f9f9; }
.lfloat { float:left; margin-right:0.5em; }
.rfloat { float:right; margin-left:0.5em; }
a.varlink { text-decoration:none; }
--></style> <meta name='robots' content='index,follow' />
<meta name="verify-v1" content="TtxFIEJAB6zdJ509wLxjnapQzKAMNm9u0Wj4ho6wxIY=" />
</head>
<body>
<div id="page">
<!--PageHeaderFmt-->
<div id="pageheader">
<div class="title"><a href='http://arduino.cc/en'>Arduino</a></div>
</div>
<!--/PageHeaderFmt-->
<!--PageLeftFmt-->
<div id="pagenav">
<div id="navbar">
<p><a class='wikilink' href='http://arduino.cc/en/Main/Buy'>Buy</a>
<a class='wikilink' href='http://arduino.cc/en/Main/Software'>Download</a>
<a class='wikilink' href='Guide_index.html'>Getting Started</a>
<a class='wikilink' href='http://arduino.cc/en/Tutorial/HomePage'>Learning</a>
<a class='wikilink' href='index.html'>Reference</a>
<a class='wikilink' href='http://arduino.cc/en/Main/Hardware'>Hardware</a>
<a class='wikilink' href='FAQ.html'>FAQ</a>
</p>
<p class='vspace'></p>
</div>
</div>
<!--/PageLeftFmt-->
<div id="pagetext">
<!--PageText-->
<div id='wikitext'>
<p><strong>Reference</strong> &nbsp; <a class='wikilink' href='index.html'>Language</a> | <a class='wikilink' href='Libraries.html'>Libraries</a> | <a class='wikilink' href='Comparison.html'>Comparison</a> | <a class='wikilink' href='Changes.html'>Changes</a>
</p>
<p class='vspace'></p><h2>bitshift left (&lt;&lt;), bitshift right (&gt;&gt;)</h2>
<h4>Description</h4>
<p>From <em>The Bitmath Tutorial</em> in The Playground
</p>
<p class='vspace'></p><p>There are two bit shift operators in C++: the left shift operator &lt;&lt; and the right shift operator &gt;&gt;. These operators cause the bits in the left operand to be shifted left or right by the number of positions specified by the right operand.<br /><br />More on bitwise math may be found <a class='urllink' href='http://www.arduino.cc/playground/Code/BitMath' rel='nofollow'>here.</a>
</p>
<p class='vspace'></p><h4>Syntax</h4>
<p>variable &lt;&lt; number_of_bits
</p>
<p class='vspace'></p><p>variable &gt;&gt; number_of_bits
</p>
<p class='vspace'></p><h4>Parameters</h4>
<p>variable - (byte, int, long)
number_of_bits integer &lt;= 32
</p>
<p class='vspace'></p><h4>Example:</h4>
<pre> int a = 5; // binary: 0000000000000101
int b = a &lt;&lt; 3; // binary: 0000000000101000, or 40 in decimal
int c = b &gt;&gt; 3; // binary: 0000000000000101, or back to 5 like we started with
</pre>
<p class='vspace'></p><p>When you shift a value x by y bits (x &lt;&lt; y), the leftmost y bits in x are lost, literally shifted out of existence:
</p>
<p class='vspace'></p><pre> int a = 5; // binary: 0000000000000101
int b = a &lt;&lt; 14; // binary: 0100000000000000 - the first 1 in 101 was discarded
</pre>
<p class='vspace'></p><p>If you are certain that none of the ones in a value are being shifted into oblivion, a simple way to think of the left-shift operator is that it multiplies the left operand by 2 raised to the right operand power. For example, to generate powers of 2, the following expressions can be employed:
</p>
<p class='vspace'></p><pre> 1 &lt;&lt; 0 == 1
1 &lt;&lt; 1 == 2
1 &lt;&lt; 2 == 4
1 &lt;&lt; 3 == 8
...
1 &lt;&lt; 8 == 256
1 &lt;&lt; 9 == 512
1 &lt;&lt; 10 == 1024
...
</pre>
<p class='vspace'></p><p>When you shift x right by y bits (x &gt;&gt; y), and the highest bit in x is a 1, the behavior depends on the exact data type of x. If x is of type int, the highest bit is the sign bit, determining whether x is negative or not, as we have discussed above. In that case, the sign bit is copied into lower bits, for esoteric historical reasons:
</p>
<p class='vspace'></p><pre> int x = -16; // binary: 1111111111110000
int y = x &gt;&gt; 3; // binary: 1111111111111110
</pre>
<p class='vspace'></p><p>This behavior, called sign extension, is often not the behavior you want. Instead, you may wish zeros to be shifted in from the left. It turns out that the right shift rules are different for unsigned int expressions, so you can use a typecast to suppress ones being copied from the left:
</p>
<p class='vspace'></p><pre> int x = -16; // binary: 1111111111110000
int y = (unsigned int)x &gt;&gt; 3; // binary: 0001111111111110
</pre>
<p class='vspace'></p><p>If you are careful to avoid sign extension, you can use the right-shift operator &gt;&gt; as a way to divide by powers of 2. For example:
</p>
<p class='vspace'></p><pre> int x = 1000;
int y = x &gt;&gt; 3; // integer division of 1000 by 8, causing y = 125.
</pre>
<p class='vspace'></p><p><a class='wikilink' href='index.html'>Reference Home</a>
</p>
<p class='vspace'></p><p><em>Corrections, suggestions, and new documentation should be posted to the <a class='urllink' href='http://arduino.cc/forum/index.php/board,23.0.html' rel='nofollow'>Forum</a>.</em>
</p>
<p class='vspace'></p><p>The text of the Arduino reference is licensed under a
<a class='urllink' href='http://creativecommons.org/licenses/by-sa/3.0/' rel='nofollow'>Creative Commons Attribution-ShareAlike 3.0 License</a>. Code samples in the reference are released into the public domain.
</p>
</div>
</div>
<!--PageFooterFmt-->
<div id="pagefooter">
&copy;Arduino |
<a href='#'>Edit Page</a> | <a href='#'>Page History</a> | <a href='#' target='_blank'>Printable View</a> | <a href='http://arduino.cc/en/Site/AllRecentChanges'>All Recent Site Changes</a>
</div>
<!--/PageFooterFmt-->
</div>
</body>
</html>

View File

@@ -0,0 +1,192 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>Arduino Reference - BitwiseAnd </title>
<link rel="shortcut icon" type="image/x-icon" href="http://arduino.cc/en/favicon.png">
<link rel='stylesheet' href='arduinoWideRender.css'
type='text/css' />
<!--HeaderText--><style type='text/css'><!--
ul, ol, pre, dl, p { margin-top:0px; margin-bottom:0px; }
code { white-space: nowrap; }
.vspace { margin-top:1.33em; }
.indent { margin-left:40px; }
.outdent { margin-left:40px; text-indent:-40px; }
a.createlinktext { text-decoration:none; border-bottom:1px dotted gray; }
a.createlink { text-decoration:none; position:relative; top:-0.5em;
font-weight:bold; font-size:smaller; border-bottom:none; }
img { border:0px; }
.editconflict { color:green;
font-style:italic; margin-top:1.33em; margin-bottom:1.33em; }
table.markup { border: 2px dotted #ccf; width:90%; }
td.markup1, td.markup2 { padding-left:10px; padding-right:10px; }
td.markup1 { border-bottom: 1px solid #ccf; }
div.faq { margin-left:2em; }
div.faq p.question { margin: 1em 0 0.75em -2em; font-weight:bold; }
div.faq hr { margin-left: -2em; }
.frame
{ border:1px solid #cccccc; padding:4px; background-color:#f9f9f9; }
.lfloat { float:left; margin-right:0.5em; }
.rfloat { float:right; margin-left:0.5em; }
a.varlink { text-decoration:none; }
--></style> <meta name='robots' content='index,follow' />
<meta name="verify-v1" content="TtxFIEJAB6zdJ509wLxjnapQzKAMNm9u0Wj4ho6wxIY=" />
</head>
<body>
<div id="page">
<!--PageHeaderFmt-->
<div id="pageheader">
<div class="title"><a href='http://arduino.cc/en'>Arduino</a></div>
</div>
<!--/PageHeaderFmt-->
<!--PageLeftFmt-->
<div id="pagenav">
<div id="navbar">
<p><a class='wikilink' href='http://arduino.cc/en/Main/Buy'>Buy</a>
<a class='wikilink' href='http://arduino.cc/en/Main/Software'>Download</a>
<a class='wikilink' href='Guide_index.html'>Getting Started</a>
<a class='wikilink' href='http://arduino.cc/en/Tutorial/HomePage'>Learning</a>
<a class='wikilink' href='index.html'>Reference</a>
<a class='wikilink' href='http://arduino.cc/en/Main/Hardware'>Hardware</a>
<a class='wikilink' href='FAQ.html'>FAQ</a>
</p>
<p class='vspace'></p>
</div>
</div>
<!--/PageLeftFmt-->
<div id="pagetext">
<!--PageText-->
<div id='wikitext'>
<p><strong>Reference</strong> &nbsp; <a class='wikilink' href='index.html'>Language</a> | <a class='wikilink' href='Libraries.html'>Libraries</a> | <a class='wikilink' href='Comparison.html'>Comparison</a> | <a class='wikilink' href='Changes.html'>Changes</a>
</p>
<p class='vspace'></p><h2>Bitwise AND (&amp;), Bitwise OR (|), Bitwise XOR (^)</h2>
<h4>Bitwise AND (&amp;)</h4>
<p>The bitwise operators perform their calculations at the bit level of variables. They help solve a wide range of common programming problems. Much of the material below is from an excellent tutorial on bitwise math wihch may be found <a class='urllink' href='http://www.arduino.cc/playground/Code/BitMath' rel='nofollow'>here.</a>
</p>
<p class='vspace'></p><h4>Description and Syntax</h4>
<p>Below are descriptions and syntax for all of the operators. Further details may be found in the referenced tutorial.
</p>
<p class='vspace'></p><h4>Bitwise AND (&amp;)</h4>
<p>The bitwise AND operator in C++ is a single ampersand, &amp;, used between two other integer expressions. Bitwise AND operates on each bit position of the surrounding expressions independently, according to this rule: if both input bits are 1, the resulting output is 1, otherwise the output is 0. Another way of expressing this is:
</p>
<p class='vspace'></p><pre> 0 0 1 1 operand1
0 1 0 1 operand2
----------
0 0 0 1 (operand1 &amp; operand2) - returned result
</pre>
<p class='vspace'></p><p>In Arduino, the type int is a 16-bit value, so using &amp; between two int expressions causes 16 simultaneous AND operations to occur. In a code fragment like:
</p>
<p class='vspace'></p><pre> int a = 92; // in binary: 0000000001011100
int b = 101; // in binary: 0000000001100101
int c = a &amp; b; // result: 0000000001000100, or 68 in decimal.
</pre>
<p class='vspace'></p><p>Each of the 16 bits in a and b are processed by using the bitwise AND, and all 16 resulting bits are stored in c, resulting in the value 01000100 in binary, which is 68 in decimal.
</p>
<p class='vspace'></p><p>One of the most common uses of bitwise AND is to select a particular bit (or bits) from an integer value, often called masking. See below for an example
</p>
<p class='vspace'></p><h4>Bitwise OR (|)</h4>
<p>The bitwise OR operator in C++ is the vertical bar symbol, |. Like the &amp; operator, | operates independently each bit in its two surrounding integer expressions, but what it does is different (of course). The bitwise OR of two bits is 1 if either or both of the input bits is 1, otherwise it is 0. In other words:
</p>
<p class='vspace'></p><pre> 0 0 1 1 operand1
0 1 0 1 operand2
----------
0 1 1 1 (operand1 | operand2) - returned result
</pre>
<p class='vspace'></p><p>Here is an example of the bitwise OR used in a snippet of C++ code:
</p>
<p class='vspace'></p><pre> int a = 92; // in binary: 0000000001011100
int b = 101; // in binary: 0000000001100101
int c = a | b; // result: 0000000001111101, or 125 in decimal.
</pre>
<p class='vspace'></p><h4>Example Program</h4>
<p>A common job for the bitwise AND and OR operators is what programmers call Read-Modify-Write on a port. On microcontrollers, a port is an 8 bit number that represents something about the condition of the pins. Writing to a port controls all of the pins at once.
</p>
<p class='vspace'></p><p>PORTD is a built-in constant that refers to the output states of digital pins 0,1,2,3,4,5,6,7. If there is 1 in an bit position, then that pin is HIGH. (The pins already need to be set to outputs with the pinMode() command.) So if we write <code>PORTD = B00110001;</code> we have made pins 2,3 &amp; 7 HIGH.
One slight hitch here is that we <em>may</em> also have changeed the state of Pins 0 &amp; 1, which are used by the Arduino for serial communications so we may have interfered with serial communication.
</p>
<p class='vspace'></p><pre> Our algorithm for the program is:
</pre><ul><li>Get PORTD and clear out only the bits corresponding to the pins we wish to control (with bitwise AND).
</li><li>Combine the modified PORTD value with the new value for the pins under control (with biwise OR).
</li></ul><p class='vspace'></p><pre>int i; // counter variable
int j;
void setup(){
DDRD = DDRD | B11111100; // set direction bits for pins 2 to 7, leave 0 and 1 untouched (xx | 00 == xx)
// same as pinMode(pin, OUTPUT) for pins 2 to 7
Serial.begin(9600);
}
void loop(){
for (i=0; i&lt;64; i++){
PORTD = PORTD &amp; B00000011; // clear out bits 2 - 7, leave pins 0 and 1 untouched (xx &amp; 11 == xx)
j = (i &lt;&lt; 2); // shift variable up to pins 2 - 7 - to avoid pins 0 and 1
PORTD = PORTD | j; // combine the port information with the new information for LED pins
Serial.println(PORTD, BIN); // debug to show masking
delay(100);
}
}
</pre>
<p class='vspace'></p><h4>Bitwise XOR (^)</h4>
<p>There is a somewhat unusual operator in C++ called bitwise EXCLUSIVE OR, also known as bitwise XOR. (In English this is usually pronounced "eks-or".) The bitwise XOR operator is written using the caret symbol ^. This operator is very similar to the bitwise OR operator |, only it evaluates to 0 for a given bit position when both of the input bits for that position are 1:
</p>
<p class='vspace'></p><pre> 0 0 1 1 operand1
0 1 0 1 operand2
----------
0 1 1 0 (operand1 ^ operand2) - returned result
</pre>
<p class='vspace'></p><p>Another way to look at bitwise XOR is that each bit in the result is a 1 if the input bits are different, or 0 if they are the same.
</p>
<p class='vspace'></p><p>Here is a simple code example:
</p>
<p class='vspace'></p><pre> int x = 12; // binary: 1100
int y = 10; // binary: 1010
int z = x ^ y; // binary: 0110, or decimal 6
</pre>
<p class='vspace'></p><p>The ^ operator is often used to toggle (i.e. change from 0 to 1, or 1 to 0) some of the bits in an integer expression. In a bitwise OR operation if there is a 1 in the mask bit, that bit is inverted; if there is a 0, the bit is not inverted and stays the same. Below is a program to blink digital pin 5.
</p>
<p class='vspace'></p><pre>
// Blink_Pin_5
// demo for Exclusive OR
void setup(){
DDRD = DDRD | B00100000; // set digital pin five as OUTPUT
Serial.begin(9600);
}
void loop(){
PORTD = PORTD ^ B00100000; // invert bit 5 (digital pin 5), leave others untouched
delay(100);
}
</pre>
<p class='vspace'></p><p>See Also
</p><ul><li><a class='wikilink' href='Boolean.html'>&amp;&amp;</a>(Boolean AND)
</li><li><a class='wikilink' href='Boolean.html'>||</a>(Boolean OR)
</li></ul><p><a class='wikilink' href='index.html'>Reference Home</a>
</p>
<p class='vspace'></p><p><em>Corrections, suggestions, and new documentation should be posted to the <a class='urllink' href='http://arduino.cc/forum/index.php/board,23.0.html' rel='nofollow'>Forum</a>.</em>
</p>
<p class='vspace'></p><p>The text of the Arduino reference is licensed under a
<a class='urllink' href='http://creativecommons.org/licenses/by-sa/3.0/' rel='nofollow'>Creative Commons Attribution-ShareAlike 3.0 License</a>. Code samples in the reference are released into the public domain.
</p>
</div>
</div>
<!--PageFooterFmt-->
<div id="pagefooter">
&copy;Arduino |
<a href='#'>Edit Page</a> | <a href='#'>Page History</a> | <a href='#' target='_blank'>Printable View</a> | <a href='http://arduino.cc/en/Site/AllRecentChanges'>All Recent Site Changes</a>
</div>
<!--/PageFooterFmt-->
</div>
</body>
</html>

View File

@@ -0,0 +1,149 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>Arduino Reference - BitwiseCompoundAnd </title>
<link rel="shortcut icon" type="image/x-icon" href="http://arduino.cc/en/favicon.png">
<link rel='stylesheet' href='arduinoWideRender.css'
type='text/css' />
<!--HeaderText--><style type='text/css'><!--
ul, ol, pre, dl, p { margin-top:0px; margin-bottom:0px; }
code { white-space: nowrap; }
.vspace { margin-top:1.33em; }
.indent { margin-left:40px; }
.outdent { margin-left:40px; text-indent:-40px; }
a.createlinktext { text-decoration:none; border-bottom:1px dotted gray; }
a.createlink { text-decoration:none; position:relative; top:-0.5em;
font-weight:bold; font-size:smaller; border-bottom:none; }
img { border:0px; }
.editconflict { color:green;
font-style:italic; margin-top:1.33em; margin-bottom:1.33em; }
table.markup { border: 2px dotted #ccf; width:90%; }
td.markup1, td.markup2 { padding-left:10px; padding-right:10px; }
td.markup1 { border-bottom: 1px solid #ccf; }
div.faq { margin-left:2em; }
div.faq p.question { margin: 1em 0 0.75em -2em; font-weight:bold; }
div.faq hr { margin-left: -2em; }
.frame
{ border:1px solid #cccccc; padding:4px; background-color:#f9f9f9; }
.lfloat { float:left; margin-right:0.5em; }
.rfloat { float:right; margin-left:0.5em; }
a.varlink { text-decoration:none; }
--></style> <meta name='robots' content='index,follow' />
<meta name="verify-v1" content="TtxFIEJAB6zdJ509wLxjnapQzKAMNm9u0Wj4ho6wxIY=" />
</head>
<body>
<div id="page">
<!--PageHeaderFmt-->
<div id="pageheader">
<div class="title"><a href='http://arduino.cc/en'>Arduino</a></div>
</div>
<!--/PageHeaderFmt-->
<!--PageLeftFmt-->
<div id="pagenav">
<div id="navbar">
<p><a class='wikilink' href='http://arduino.cc/en/Main/Buy'>Buy</a>
<a class='wikilink' href='http://arduino.cc/en/Main/Software'>Download</a>
<a class='wikilink' href='Guide_index.html'>Getting Started</a>
<a class='wikilink' href='http://arduino.cc/en/Tutorial/HomePage'>Learning</a>
<a class='wikilink' href='index.html'>Reference</a>
<a class='wikilink' href='http://arduino.cc/en/Main/Hardware'>Hardware</a>
<a class='wikilink' href='FAQ.html'>FAQ</a>
</p>
<p class='vspace'></p>
</div>
</div>
<!--/PageLeftFmt-->
<div id="pagetext">
<!--PageText-->
<div id='wikitext'>
<p><strong>Reference</strong> &nbsp; <a class='wikilink' href='index.html'>Language</a> | <a class='wikilink' href='Libraries.html'>Libraries</a> | <a class='wikilink' href='Comparison.html'>Comparison</a> | <a class='wikilink' href='Changes.html'>Changes</a>
</p>
<p class='vspace'></p><h2>compound bitwise AND (&amp;=)</h2>
<h4>Description </h4>
<p>The compound bitwise AND operator (&amp;=) is often used with a variable and a constant to force particular bits in a variable to the LOW state (to 0). This is often referred to in programming guides as "clearing" or "resetting" bits.
</p>
<p class='vspace'></p><h4>Syntax:</h4>
<pre>
x &amp;= y; // equivalent to x = x &amp; y;
</pre>
<p class='vspace'></p><h4>Parameters</h4>
<p>x: a char, int or long variable<br />y: an integer constant or char, int, or long
</p>
<p class='vspace'></p><h4>Example:</h4>
<p>First, a review of the Bitwise AND (&amp;) operator
</p><pre>
0 0 1 1 operand1
0 1 0 1 operand2
----------
0 0 0 1 (operand1 &amp; operand2) - returned result
</pre>
<p class='vspace'></p><p>Bits that are "bitwise <span class='wikiword'>ANDed</span>" with 0 are cleared to 0 so, if myByte is a byte variable,<br />
<code>myByte &amp; B00000000 = 0;</code>
</p>
<p class='vspace'></p><p>Bits that are "bitwise <span class='wikiword'>ANDed</span>" with 1 are unchanged so, <br />
<code>myByte &amp; B11111111 = myByte;</code>
</p>
<p class='vspace'></p><p>Note: because we are dealing with bits in a bitwise operator - it is convenient to use the binary formatter with <a class='wikilink' href='IntegerConstants.html'>constants.</a> The numbers are still the same value in other representations, they are just not as easy to understand. Also, B00000000 is shown for clarity, but zero in any number format is zero (hmmm something philosophical there?)
</p>
<p class='vspace'></p><p>Consequently - to clear (set to zero) bits 0 &amp; 1 of a variable, while leaving the rest of the variable unchanged, use the compound bitwise AND operator (&amp;=) with the constant B11111100
</p><pre>
1 0 1 0 1 0 1 0 variable
1 1 1 1 1 1 0 0 mask
----------------------
1 0 1 0 1 0 0 0
variable unchanged
bits cleared
</pre><p>Here is the same representation with the variable's bits replaced with the symbol x
</p>
<p class='vspace'></p><pre>
x x x x x x x x variable
1 1 1 1 1 1 0 0 mask
----------------------
x x x x x x 0 0
variable unchanged
bits cleared
</pre><p>So if:
</p><pre>
myByte = 10101010;
myByte &amp;= B1111100 == B10101000;
</pre>
<p class='vspace'></p><p>See Also
</p><ul><li><a class='wikilink' href='BitwiseCompoundOr.html'>|=</a> (compound bitwise or)
</li><li><a class='wikilink' href='BitwiseAnd.html'>&amp;</a> (bitwise AND)
</li><li><a class='wikilink' href='BitwiseAnd.html'>|</a> (bitwise OR)
</li></ul><p><a class='wikilink' href='index.html'>Reference Home</a>
</p>
<p class='vspace'></p><p><em>Corrections, suggestions, and new documentation should be posted to the <a class='urllink' href='http://arduino.cc/forum/index.php/board,23.0.html' rel='nofollow'>Forum</a>.</em>
</p>
<p class='vspace'></p><p>The text of the Arduino reference is licensed under a
<a class='urllink' href='http://creativecommons.org/licenses/by-sa/3.0/' rel='nofollow'>Creative Commons Attribution-ShareAlike 3.0 License</a>. Code samples in the reference are released into the public domain.
</p>
</div>
</div>
<!--PageFooterFmt-->
<div id="pagefooter">
&copy;Arduino |
<a href='#'>Edit Page</a> | <a href='#'>Page History</a> | <a href='#' target='_blank'>Printable View</a> | <a href='http://arduino.cc/en/Site/AllRecentChanges'>All Recent Site Changes</a>
</div>
<!--/PageFooterFmt-->
</div>
</body>
</html>

View File

@@ -0,0 +1,147 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>Arduino Reference - BitwiseCompoundOr </title>
<link rel="shortcut icon" type="image/x-icon" href="http://arduino.cc/en/favicon.png">
<link rel='stylesheet' href='arduinoWideRender.css'
type='text/css' />
<!--HeaderText--><style type='text/css'><!--
ul, ol, pre, dl, p { margin-top:0px; margin-bottom:0px; }
code { white-space: nowrap; }
.vspace { margin-top:1.33em; }
.indent { margin-left:40px; }
.outdent { margin-left:40px; text-indent:-40px; }
a.createlinktext { text-decoration:none; border-bottom:1px dotted gray; }
a.createlink { text-decoration:none; position:relative; top:-0.5em;
font-weight:bold; font-size:smaller; border-bottom:none; }
img { border:0px; }
.editconflict { color:green;
font-style:italic; margin-top:1.33em; margin-bottom:1.33em; }
table.markup { border: 2px dotted #ccf; width:90%; }
td.markup1, td.markup2 { padding-left:10px; padding-right:10px; }
td.markup1 { border-bottom: 1px solid #ccf; }
div.faq { margin-left:2em; }
div.faq p.question { margin: 1em 0 0.75em -2em; font-weight:bold; }
div.faq hr { margin-left: -2em; }
.frame
{ border:1px solid #cccccc; padding:4px; background-color:#f9f9f9; }
.lfloat { float:left; margin-right:0.5em; }
.rfloat { float:right; margin-left:0.5em; }
a.varlink { text-decoration:none; }
--></style> <meta name='robots' content='index,follow' />
<meta name="verify-v1" content="TtxFIEJAB6zdJ509wLxjnapQzKAMNm9u0Wj4ho6wxIY=" />
</head>
<body>
<div id="page">
<!--PageHeaderFmt-->
<div id="pageheader">
<div class="title"><a href='http://arduino.cc/en'>Arduino</a></div>
</div>
<!--/PageHeaderFmt-->
<!--PageLeftFmt-->
<div id="pagenav">
<div id="navbar">
<p><a class='wikilink' href='http://arduino.cc/en/Main/Buy'>Buy</a>
<a class='wikilink' href='http://arduino.cc/en/Main/Software'>Download</a>
<a class='wikilink' href='Guide_index.html'>Getting Started</a>
<a class='wikilink' href='http://arduino.cc/en/Tutorial/HomePage'>Learning</a>
<a class='wikilink' href='index.html'>Reference</a>
<a class='wikilink' href='http://arduino.cc/en/Main/Hardware'>Hardware</a>
<a class='wikilink' href='FAQ.html'>FAQ</a>
</p>
<p class='vspace'></p>
</div>
</div>
<!--/PageLeftFmt-->
<div id="pagetext">
<!--PageText-->
<div id='wikitext'>
<p><strong>Reference</strong> &nbsp; <a class='wikilink' href='index.html'>Language</a> | <a class='wikilink' href='Libraries.html'>Libraries</a> | <a class='wikilink' href='Comparison.html'>Comparison</a> | <a class='wikilink' href='Changes.html'>Changes</a>
</p>
<p class='vspace'></p><h2>compound bitwise OR (|=)</h2>
<h4>Description </h4>
<p>The compound bitwise OR operator (|=) is often used with a variable and a constant to "set" (set to 1) particular bits in a variable.
</p>
<p class='vspace'></p><h4>Syntax:</h4>
<pre>
x |= y; // equivalent to x = x | y;
</pre>
<p class='vspace'></p><h4>Parameters</h4>
<p>x: a char, int or long variable<br />y: an integer constant or char, int, or long
</p>
<p class='vspace'></p><h4>Example:</h4>
<p>First, a review of the Bitwise OR (|) operator
</p><pre>
0 0 1 1 operand1
0 1 0 1 operand2
----------
0 1 1 1 (operand1 | operand2) - returned result
</pre><p>Bits that are "bitwise <span class='wikiword'>ORed</span>" with 0 are unchanged, so if myByte is a byte variable,<br />
myByte | B00000000 = myByte;
</p>
<p class='vspace'></p><p>Bits that are "bitwise <span class='wikiword'>ORed</span>" with 1 are set to 1 so:<br />myByte | B11111111 = B11111111;
</p>
<p class='vspace'></p><p>Consequently - to set bits 0 &amp; 1 of a variable, while leaving the rest of the variable unchanged, use the compound bitwise AND operator (|=) with the constant B00000011
</p><pre>
1 0 1 0 1 0 1 0 variable
0 0 0 0 0 0 1 1 mask
----------------------
1 0 1 0 1 0 1 1
variable unchanged
bits set
</pre><p>Here is the same representation with the variables bits replaced with the symbol x
</p>
<p class='vspace'></p><pre>
x x x x x x x x variable
0 0 0 0 0 0 1 1 mask
----------------------
x x x x x x 1 1
variable unchanged
bits set
</pre><p>So if:
</p><pre>
myByte = B10101010;
myByte |= B00000011 == B10101011;
</pre>
<p class='vspace'></p><p>See Also
</p><ul><li><a class='wikilink' href='BitwiseCompoundAnd.html'>&amp;=</a> (compound bitwise and)
</li><li><a class='wikilink' href='BitwiseAnd.html'>&amp;</a> (bitwise and)
</li><li><a class='wikilink' href='BitwiseAnd.html'>|</a> (bitwise or)
</li></ul><p><a class='wikilink' href='index.html'>Reference Home</a>
</p>
<p class='vspace'></p><p><em>Corrections, suggestions, and new documentation should be posted to the <a class='urllink' href='http://arduino.cc/forum/index.php/board,23.0.html' rel='nofollow'>Forum</a>.</em>
</p>
<p class='vspace'></p><p>The text of the Arduino reference is licensed under a
<a class='urllink' href='http://creativecommons.org/licenses/by-sa/3.0/' rel='nofollow'>Creative Commons Attribution-ShareAlike 3.0 License</a>. Code samples in the reference are released into the public domain.
</p>
</div>
</div>
<!--PageFooterFmt-->
<div id="pagefooter">
&copy;Arduino |
<a href='#'>Edit Page</a> | <a href='#'>Page History</a> | <a href='#' target='_blank'>Printable View</a> | <a href='http://arduino.cc/en/Site/AllRecentChanges'>All Recent Site Changes</a>
</div>
<!--/PageFooterFmt-->
</div>
</body>
</html>

View File

@@ -0,0 +1,107 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>Arduino Reference - BitwiseXorNot </title>
<link rel="shortcut icon" type="image/x-icon" href="http://arduino.cc/en/favicon.png">
<link rel='stylesheet' href='arduinoWideRender.css'
type='text/css' />
<!--HeaderText--><style type='text/css'><!--
ul, ol, pre, dl, p { margin-top:0px; margin-bottom:0px; }
code { white-space: nowrap; }
.vspace { margin-top:1.33em; }
.indent { margin-left:40px; }
.outdent { margin-left:40px; text-indent:-40px; }
a.createlinktext { text-decoration:none; border-bottom:1px dotted gray; }
a.createlink { text-decoration:none; position:relative; top:-0.5em;
font-weight:bold; font-size:smaller; border-bottom:none; }
img { border:0px; }
.editconflict { color:green;
font-style:italic; margin-top:1.33em; margin-bottom:1.33em; }
table.markup { border: 2px dotted #ccf; width:90%; }
td.markup1, td.markup2 { padding-left:10px; padding-right:10px; }
td.markup1 { border-bottom: 1px solid #ccf; }
div.faq { margin-left:2em; }
div.faq p.question { margin: 1em 0 0.75em -2em; font-weight:bold; }
div.faq hr { margin-left: -2em; }
.frame
{ border:1px solid #cccccc; padding:4px; background-color:#f9f9f9; }
.lfloat { float:left; margin-right:0.5em; }
.rfloat { float:right; margin-left:0.5em; }
a.varlink { text-decoration:none; }
--></style> <meta name='robots' content='index,follow' />
<meta name="verify-v1" content="TtxFIEJAB6zdJ509wLxjnapQzKAMNm9u0Wj4ho6wxIY=" />
</head>
<body>
<div id="page">
<!--PageHeaderFmt-->
<div id="pageheader">
<div class="title"><a href='http://arduino.cc/en'>Arduino</a></div>
</div>
<!--/PageHeaderFmt-->
<!--PageLeftFmt-->
<div id="pagenav">
<div id="navbar">
<p><a class='wikilink' href='http://arduino.cc/en/Main/Buy'>Buy</a>
<a class='wikilink' href='http://arduino.cc/en/Main/Software'>Download</a>
<a class='wikilink' href='Guide_index.html'>Getting Started</a>
<a class='wikilink' href='http://arduino.cc/en/Tutorial/HomePage'>Learning</a>
<a class='wikilink' href='index.html'>Reference</a>
<a class='wikilink' href='http://arduino.cc/en/Main/Hardware'>Hardware</a>
<a class='wikilink' href='FAQ.html'>FAQ</a>
</p>
<p class='vspace'></p>
</div>
</div>
<!--/PageLeftFmt-->
<div id="pagetext">
<!--PageText-->
<div id='wikitext'>
<p><strong>Reference</strong> &nbsp; <a class='wikilink' href='index.html'>Language</a> | <a class='wikilink' href='Libraries.html'>Libraries</a> | <a class='wikilink' href='Comparison.html'>Comparison</a> | <a class='wikilink' href='Changes.html'>Changes</a>
</p>
<p class='vspace'></p><h2>Bitwise NOT (~)</h2>
<p>The bitwise NOT operator in C++ is the tilde character ~. Unlike &amp; and |, the bitwise NOT operator is applied to a single operand to its right. Bitwise NOT changes each bit to its opposite: 0 becomes 1, and 1 becomes 0. For example:
</p>
<p class='vspace'></p><pre> 0 1 operand1
</pre>
<p class='vspace'></p><pre> ----------
1 0 ~ operand1
</pre>
<p class='vspace'></p><pre> int a = 103; // binary: 0000000001100111
int b = ~a; // binary: 1111111110011000 = -104
</pre>
<p class='vspace'></p><p>You might be surprised to see a negative number like -104 as the result of this operation. This is because the highest bit in an int variable is the so-called sign bit. If the highest bit is 1, the number is interpreted as negative. This encoding of positive and negative numbers is referred to as two's complement. For more information, see the Wikipedia article on <a class='urllink' href='http://en.wikipedia.org/wiki/Twos_complement' rel='nofollow'>two's complement.</a>
</p>
<p class='vspace'></p><p>As an aside, it is interesting to note that for any integer x, ~x is the same as -x-1.
</p>
<p class='vspace'></p><p>At times, the sign bit in a signed integer expression can cause some unwanted surprises.
</p>
<p class='vspace'></p><p><a class='wikilink' href='index.html'>Reference Home</a>
</p>
<p class='vspace'></p><p><em>Corrections, suggestions, and new documentation should be posted to the <a class='urllink' href='http://arduino.cc/forum/index.php/board,23.0.html' rel='nofollow'>Forum</a>.</em>
</p>
<p class='vspace'></p><p>The text of the Arduino reference is licensed under a
<a class='urllink' href='http://creativecommons.org/licenses/by-sa/3.0/' rel='nofollow'>Creative Commons Attribution-ShareAlike 3.0 License</a>. Code samples in the reference are released into the public domain.
</p>
</div>
</div>
<!--PageFooterFmt-->
<div id="pagefooter">
&copy;Arduino |
<a href='#'>Edit Page</a> | <a href='#'>Page History</a> | <a href='#' target='_blank'>Printable View</a> | <a href='http://arduino.cc/en/Site/AllRecentChanges'>All Recent Site Changes</a>
</div>
<!--/PageFooterFmt-->
</div>
</body>
</html>

View File

@@ -0,0 +1,134 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>Arduino Reference - Boolean </title>
<link rel="shortcut icon" type="image/x-icon" href="http://arduino.cc/en/favicon.png">
<link rel='stylesheet' href='arduinoWideRender.css'
type='text/css' />
<!--HeaderText--><style type='text/css'><!--
ul, ol, pre, dl, p { margin-top:0px; margin-bottom:0px; }
code { white-space: nowrap; }
.vspace { margin-top:1.33em; }
.indent { margin-left:40px; }
.outdent { margin-left:40px; text-indent:-40px; }
a.createlinktext { text-decoration:none; border-bottom:1px dotted gray; }
a.createlink { text-decoration:none; position:relative; top:-0.5em;
font-weight:bold; font-size:smaller; border-bottom:none; }
img { border:0px; }
.editconflict { color:green;
font-style:italic; margin-top:1.33em; margin-bottom:1.33em; }
table.markup { border: 2px dotted #ccf; width:90%; }
td.markup1, td.markup2 { padding-left:10px; padding-right:10px; }
td.markup1 { border-bottom: 1px solid #ccf; }
div.faq { margin-left:2em; }
div.faq p.question { margin: 1em 0 0.75em -2em; font-weight:bold; }
div.faq hr { margin-left: -2em; }
.frame
{ border:1px solid #cccccc; padding:4px; background-color:#f9f9f9; }
.lfloat { float:left; margin-right:0.5em; }
.rfloat { float:right; margin-left:0.5em; }
a.varlink { text-decoration:none; }
--></style> <meta name='robots' content='index,follow' />
<meta name="verify-v1" content="TtxFIEJAB6zdJ509wLxjnapQzKAMNm9u0Wj4ho6wxIY=" />
</head>
<body>
<div id="page">
<!--PageHeaderFmt-->
<div id="pageheader">
<div class="title"><a href='http://arduino.cc/en'>Arduino</a></div>
</div>
<!--/PageHeaderFmt-->
<!--PageLeftFmt-->
<div id="pagenav">
<div id="navbar">
<p><a class='wikilink' href='http://arduino.cc/en/Main/Buy'>Buy</a>
<a class='wikilink' href='http://arduino.cc/en/Main/Software'>Download</a>
<a class='wikilink' href='Guide_index.html'>Getting Started</a>
<a class='wikilink' href='http://arduino.cc/en/Tutorial/HomePage'>Learning</a>
<a class='wikilink' href='index.html'>Reference</a>
<a class='wikilink' href='http://arduino.cc/en/Main/Hardware'>Hardware</a>
<a class='wikilink' href='FAQ.html'>FAQ</a>
</p>
<p class='vspace'></p>
</div>
</div>
<!--/PageLeftFmt-->
<div id="pagetext">
<!--PageText-->
<div id='wikitext'>
<p><strong>Reference</strong> &nbsp; <a class='wikilink' href='index.html'>Language</a> | <a class='wikilink' href='Libraries.html'>Libraries</a> | <a class='wikilink' href='Comparison.html'>Comparison</a> | <a class='wikilink' href='Changes.html'>Changes</a>
</p>
<p class='vspace'></p><h1>Boolean Operators </h1>
<p>These can be used inside the condition of an <a class='wikilink' href='If.html'>if</a> statement.
</p>
<p class='vspace'></p><h3>&amp;&amp; (logical and)</h3>
<p>True only if both operands are true, e.g.
</p><pre>
if (digitalRead(2) == HIGH &amp;&amp; digitalRead(3) == HIGH) { // read two switches
// ...
}
</pre><p>is true only if both inputs are high.
</p>
<p class='vspace'></p><h3>|| (logical or)</h3>
<p>True if either operand is true, e.g.
</p><pre>
if (x &gt; 0 || y &gt; 0) {
// ...
}
</pre><p>is true if either x or y is greater than 0.
</p>
<p class='vspace'></p><h3>! (not)</h3>
<p>True if the operand is false, e.g.
</p><pre>
if (!x) {
// ...
}
</pre><p>is true if x is false (i.e. if x equals 0).
</p>
<p class='vspace'></p><h4>Warning</h4>
<p>Make sure you don't mistake the boolean AND operator, &amp;&amp; (double ampersand) for the bitwise AND operator &amp; (single ampersand). They are entirely different beasts.
</p>
<p class='vspace'></p><p>Similarly, do not confuse the boolean || (double pipe) operator with the bitwise OR operator | (single pipe).
</p>
<p class='vspace'></p><p>The bitwise not ~ (tilde) looks much different than the boolean not ! (exclamation point or "bang" as the programmers say) but you still have to be sure which one you want where.
</p>
<p class='vspace'></p><h4>Examples</h4>
<pre>
if (a &gt;= 10 &amp;&amp; a &lt;= 20){} // true if a is between 10 and 20
</pre>
<p class='vspace'></p><h4>See also</h4>
<ul><li><a class='wikilink' href='BitwiseAnd.html'>&amp;</a> (bitwise AND)
</li><li><a class='wikilink' href='BitwiseAnd.html'>|</a> (bitwise OR)
</li><li><a class='wikilink' href='BitwiseXorNot.html'>~</a> (bitwise NOT
</li><li><a class='wikilink' href='If.html'>if</a>
</li></ul><p class='vspace'></p><p><a class='wikilink' href='index.html'>Reference Home</a>
</p>
<p class='vspace'></p><p><em>Corrections, suggestions, and new documentation should be posted to the <a class='urllink' href='http://arduino.cc/forum/index.php/board,23.0.html' rel='nofollow'>Forum</a>.</em>
</p>
<p class='vspace'></p><p>The text of the Arduino reference is licensed under a
<a class='urllink' href='http://creativecommons.org/licenses/by-sa/3.0/' rel='nofollow'>Creative Commons Attribution-ShareAlike 3.0 License</a>. Code samples in the reference are released into the public domain.
</p>
</div>
</div>
<!--PageFooterFmt-->
<div id="pagefooter">
&copy;Arduino |
<a href='#'>Edit Page</a> | <a href='#'>Page History</a> | <a href='#' target='_blank'>Printable View</a> | <a href='http://arduino.cc/en/Site/AllRecentChanges'>All Recent Site Changes</a>
</div>
<!--/PageFooterFmt-->
</div>
</body>
</html>

View File

@@ -0,0 +1,125 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>Arduino Reference - BooleanVariables </title>
<link rel="shortcut icon" type="image/x-icon" href="http://arduino.cc/en/favicon.png">
<link rel='stylesheet' href='arduinoWideRender.css'
type='text/css' />
<!--HeaderText--><style type='text/css'><!--
ul, ol, pre, dl, p { margin-top:0px; margin-bottom:0px; }
code { white-space: nowrap; }
.vspace { margin-top:1.33em; }
.indent { margin-left:40px; }
.outdent { margin-left:40px; text-indent:-40px; }
a.createlinktext { text-decoration:none; border-bottom:1px dotted gray; }
a.createlink { text-decoration:none; position:relative; top:-0.5em;
font-weight:bold; font-size:smaller; border-bottom:none; }
img { border:0px; }
.editconflict { color:green;
font-style:italic; margin-top:1.33em; margin-bottom:1.33em; }
table.markup { border: 2px dotted #ccf; width:90%; }
td.markup1, td.markup2 { padding-left:10px; padding-right:10px; }
td.markup1 { border-bottom: 1px solid #ccf; }
div.faq { margin-left:2em; }
div.faq p.question { margin: 1em 0 0.75em -2em; font-weight:bold; }
div.faq hr { margin-left: -2em; }
.frame
{ border:1px solid #cccccc; padding:4px; background-color:#f9f9f9; }
.lfloat { float:left; margin-right:0.5em; }
.rfloat { float:right; margin-left:0.5em; }
a.varlink { text-decoration:none; }
--></style> <meta name='robots' content='index,follow' />
<meta name="verify-v1" content="TtxFIEJAB6zdJ509wLxjnapQzKAMNm9u0Wj4ho6wxIY=" />
</head>
<body>
<div id="page">
<!--PageHeaderFmt-->
<div id="pageheader">
<div class="title"><a href='http://arduino.cc/en'>Arduino</a></div>
</div>
<!--/PageHeaderFmt-->
<!--PageLeftFmt-->
<div id="pagenav">
<div id="navbar">
<p><a class='wikilink' href='http://arduino.cc/en/Main/Buy'>Buy</a>
<a class='wikilink' href='http://arduino.cc/en/Main/Software'>Download</a>
<a class='wikilink' href='Guide_index.html'>Getting Started</a>
<a class='wikilink' href='http://arduino.cc/en/Tutorial/HomePage'>Learning</a>
<a class='wikilink' href='index.html'>Reference</a>
<a class='wikilink' href='http://arduino.cc/en/Main/Hardware'>Hardware</a>
<a class='wikilink' href='FAQ.html'>FAQ</a>
</p>
<p class='vspace'></p>
</div>
</div>
<!--/PageLeftFmt-->
<div id="pagetext">
<!--PageText-->
<div id='wikitext'>
<p><strong>Reference</strong> &nbsp; <a class='wikilink' href='index.html'>Language</a> | <a class='wikilink' href='Libraries.html'>Libraries</a> | <a class='wikilink' href='Comparison.html'>Comparison</a> | <a class='wikilink' href='Changes.html'>Changes</a>
</p>
<p class='vspace'></p><h2>boolean</h2>
<p>A <strong>boolean</strong> holds one of two values, <a class='wikilink' href='Constants.html'>true</a> or <a class='wikilink' href='Constants.html'>false</a>. (Each boolean variable occupies one byte of memory.)
</p>
<p class='vspace'></p><h4>Example</h4>
<pre>
int LEDpin = 5; // LED on pin 5
int switchPin = 13; // momentary switch on 13, other side connected to ground
boolean running = false;
void setup()
{
pinMode(LEDpin, OUTPUT);
pinMode(switchPin, INPUT);
digitalWrite(switchPin, HIGH); // turn on pullup resistor
}
void loop()
{
if (digitalRead(switchPin) == LOW)
{ // switch is pressed - pullup keeps pin high normally
delay(100); // delay to debounce switch
running = !running; // toggle running variable
digitalWrite(LEDpin, running) // indicate via LED
}
}
</pre>
<p class='vspace'></p><h4>See also</h4>
<ul><li><a class='wikilink' href='Constants.html'>constants</a>
</li><li><a class='wikilink' href='Boolean.html'>boolean operators</a>
</li><li><a class='urllink' href='http://arduino.cc/en/Reference/VariableDeclaration' rel='nofollow'>Variable Declaration</a>
</li></ul><p><a class='wikilink' href='index.html'>Reference Home</a>
</p>
<p class='vspace'></p><p><em>Corrections, suggestions, and new documentation should be posted to the <a class='urllink' href='http://arduino.cc/forum/index.php/board,23.0.html' rel='nofollow'>Forum</a>.</em>
</p>
<p class='vspace'></p><p>The text of the Arduino reference is licensed under a
<a class='urllink' href='http://creativecommons.org/licenses/by-sa/3.0/' rel='nofollow'>Creative Commons Attribution-ShareAlike 3.0 License</a>. Code samples in the reference are released into the public domain.
</p>
</div>
</div>
<!--PageFooterFmt-->
<div id="pagefooter">
&copy;Arduino |
<a href='#'>Edit Page</a> | <a href='#'>Page History</a> | <a href='#' target='_blank'>Printable View</a> | <a href='http://arduino.cc/en/Site/AllRecentChanges'>All Recent Site Changes</a>
</div>
<!--/PageFooterFmt-->
</div>
</body>
</html>

View File

@@ -0,0 +1,141 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>Arduino Reference - Braces </title>
<link rel="shortcut icon" type="image/x-icon" href="http://arduino.cc/en/favicon.png">
<link rel='stylesheet' href='arduinoWideRender.css'
type='text/css' />
<!--HeaderText--><style type='text/css'><!--
ul, ol, pre, dl, p { margin-top:0px; margin-bottom:0px; }
code { white-space: nowrap; }
.vspace { margin-top:1.33em; }
.indent { margin-left:40px; }
.outdent { margin-left:40px; text-indent:-40px; }
a.createlinktext { text-decoration:none; border-bottom:1px dotted gray; }
a.createlink { text-decoration:none; position:relative; top:-0.5em;
font-weight:bold; font-size:smaller; border-bottom:none; }
img { border:0px; }
.editconflict { color:green;
font-style:italic; margin-top:1.33em; margin-bottom:1.33em; }
table.markup { border: 2px dotted #ccf; width:90%; }
td.markup1, td.markup2 { padding-left:10px; padding-right:10px; }
td.markup1 { border-bottom: 1px solid #ccf; }
div.faq { margin-left:2em; }
div.faq p.question { margin: 1em 0 0.75em -2em; font-weight:bold; }
div.faq hr { margin-left: -2em; }
.frame
{ border:1px solid #cccccc; padding:4px; background-color:#f9f9f9; }
.lfloat { float:left; margin-right:0.5em; }
.rfloat { float:right; margin-left:0.5em; }
a.varlink { text-decoration:none; }
--></style> <meta name='robots' content='index,follow' />
<meta name="verify-v1" content="TtxFIEJAB6zdJ509wLxjnapQzKAMNm9u0Wj4ho6wxIY=" />
</head>
<body>
<div id="page">
<!--PageHeaderFmt-->
<div id="pageheader">
<div class="title"><a href='http://arduino.cc/en'>Arduino</a></div>
</div>
<!--/PageHeaderFmt-->
<!--PageLeftFmt-->
<div id="pagenav">
<div id="navbar">
<p><a class='wikilink' href='http://arduino.cc/en/Main/Buy'>Buy</a>
<a class='wikilink' href='http://arduino.cc/en/Main/Software'>Download</a>
<a class='wikilink' href='Guide_index.html'>Getting Started</a>
<a class='wikilink' href='http://arduino.cc/en/Tutorial/HomePage'>Learning</a>
<a class='wikilink' href='index.html'>Reference</a>
<a class='wikilink' href='http://arduino.cc/en/Main/Hardware'>Hardware</a>
<a class='wikilink' href='FAQ.html'>FAQ</a>
</p>
<p class='vspace'></p>
</div>
</div>
<!--/PageLeftFmt-->
<div id="pagetext">
<!--PageText-->
<div id='wikitext'>
<p><strong>Reference</strong> &nbsp; <a class='wikilink' href='index.html'>Language</a> | <a class='wikilink' href='Libraries.html'>Libraries</a> | <a class='wikilink' href='Comparison.html'>Comparison</a> | <a class='wikilink' href='Changes.html'>Changes</a>
</p>
<p class='vspace'></p><h2>{} Curly Braces</h2>
<p>Curly braces (also referred to as just "braces" or as "curly brackets") are a major part of the C programming language. They are used in several different constructs, outlined below, and this can sometimes be confusing for beginners.
</p>
<p class='vspace'></p><p>An opening curly brace "{" must always be followed by a closing curly brace "}". This is a condition that is often referred to as the braces being balanced. The Arduino IDE (integrated development environment) includes a convenient feature to check the balance of curly braces. Just select a brace, or even click the insertion point immediately following a brace, and its logical companion will be highlighted.
</p>
<p class='vspace'></p><p>At present this feature is slightly buggy as the IDE will often find (incorrectly) a brace in text that has been "commented out."
</p>
<p class='vspace'></p><p>Beginning programmers, and programmers coming to C from the BASIC language often find using braces confusing or daunting. After all, the same curly braces replace the RETURN statement in a subroutine (function), the ENDIF statement in a conditional and the NEXT statement in a FOR loop.
</p>
<p class='vspace'></p><p>Because the use of the curly brace is so varied, it is good programming practice to type the closing brace immediately after typing the opening brace when inserting a construct which requires curly braces. Then insert some carriage returns between your braces and begin inserting statements. Your braces, and your attitude, will never become unbalanced.
</p>
<p class='vspace'></p><p>Unbalanced braces can often lead to cryptic, impenetrable compiler errors that can sometimes be hard to track down in a large program. Because of their varied usages, braces are also incredibly important to the syntax of a program and moving a brace one or two lines will often dramatically affect the meaning of a program.
</p>
<p class='vspace'></p><h4><strong>The main uses of curly braces</strong></h4>
<h4>Functions</h4>
<pre> void myfunction(datatype argument){
statements(s)
}
</pre>
<p class='vspace'></p><h4>Loops</h4>
<pre> while (boolean expression)
{
statement(s)
}
do
{
statement(s)
} while (boolean expression);
for (initialisation; termination condition; incrementing expr)
{
statement(s)
}
</pre>
<p class='vspace'></p><h4>Conditional statements</h4>
<p class='vspace'></p><pre> if (boolean expression)
{
statement(s)
}
else if (boolean expression)
{
statement(s)
}
else
{
statement(s)
}
</pre>
<p class='vspace'></p><p><a class='wikilink' href='index.html'>Reference Home</a>
<a class='wikilink' href='index.html'>Reference Home</a>
</p>
<p class='vspace'></p><p><em>Corrections, suggestions, and new documentation should be posted to the <a class='urllink' href='http://arduino.cc/forum/index.php/board,23.0.html' rel='nofollow'>Forum</a>.</em>
</p>
<p class='vspace'></p><p>The text of the Arduino reference is licensed under a
<a class='urllink' href='http://creativecommons.org/licenses/by-sa/3.0/' rel='nofollow'>Creative Commons Attribution-ShareAlike 3.0 License</a>. Code samples in the reference are released into the public domain.
</p>
</div>
</div>
<!--PageFooterFmt-->
<div id="pagefooter">
&copy;Arduino |
<a href='#'>Edit Page</a> | <a href='#'>Page History</a> | <a href='#' target='_blank'>Printable View</a> | <a href='http://arduino.cc/en/Site/AllRecentChanges'>All Recent Site Changes</a>
</div>
<!--/PageFooterFmt-->
</div>
</body>
</html>

View File

@@ -0,0 +1,107 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>Arduino Reference - Break </title>
<link rel="shortcut icon" type="image/x-icon" href="http://arduino.cc/en/favicon.png">
<link rel='stylesheet' href='arduinoWideRender.css'
type='text/css' />
<!--HeaderText--><style type='text/css'><!--
ul, ol, pre, dl, p { margin-top:0px; margin-bottom:0px; }
code { white-space: nowrap; }
.vspace { margin-top:1.33em; }
.indent { margin-left:40px; }
.outdent { margin-left:40px; text-indent:-40px; }
a.createlinktext { text-decoration:none; border-bottom:1px dotted gray; }
a.createlink { text-decoration:none; position:relative; top:-0.5em;
font-weight:bold; font-size:smaller; border-bottom:none; }
img { border:0px; }
.editconflict { color:green;
font-style:italic; margin-top:1.33em; margin-bottom:1.33em; }
table.markup { border: 2px dotted #ccf; width:90%; }
td.markup1, td.markup2 { padding-left:10px; padding-right:10px; }
td.markup1 { border-bottom: 1px solid #ccf; }
div.faq { margin-left:2em; }
div.faq p.question { margin: 1em 0 0.75em -2em; font-weight:bold; }
div.faq hr { margin-left: -2em; }
.frame
{ border:1px solid #cccccc; padding:4px; background-color:#f9f9f9; }
.lfloat { float:left; margin-right:0.5em; }
.rfloat { float:right; margin-left:0.5em; }
a.varlink { text-decoration:none; }
--></style> <meta name='robots' content='index,follow' />
<meta name="verify-v1" content="TtxFIEJAB6zdJ509wLxjnapQzKAMNm9u0Wj4ho6wxIY=" />
</head>
<body>
<div id="page">
<!--PageHeaderFmt-->
<div id="pageheader">
<div class="title"><a href='http://arduino.cc/en'>Arduino</a></div>
</div>
<!--/PageHeaderFmt-->
<!--PageLeftFmt-->
<div id="pagenav">
<div id="navbar">
<p><a class='wikilink' href='http://arduino.cc/en/Main/Buy'>Buy</a>
<a class='wikilink' href='http://arduino.cc/en/Main/Software'>Download</a>
<a class='wikilink' href='Guide_index.html'>Getting Started</a>
<a class='wikilink' href='http://arduino.cc/en/Tutorial/HomePage'>Learning</a>
<a class='wikilink' href='index.html'>Reference</a>
<a class='wikilink' href='http://arduino.cc/en/Main/Hardware'>Hardware</a>
<a class='wikilink' href='FAQ.html'>FAQ</a>
</p>
<p class='vspace'></p>
</div>
</div>
<!--/PageLeftFmt-->
<div id="pagetext">
<!--PageText-->
<div id='wikitext'>
<p><strong>Reference</strong> &nbsp; <a class='wikilink' href='index.html'>Language</a> | <a class='wikilink' href='Libraries.html'>Libraries</a> | <a class='wikilink' href='Comparison.html'>Comparison</a> | <a class='wikilink' href='Changes.html'>Changes</a>
</p>
<p class='vspace'></p><h2>break</h2>
<p><strong>break</strong> is used to exit from a <strong>do</strong>, <strong>for</strong>, or <strong>while</strong> loop, bypassing the normal loop condition. It is also used to exit from a <strong>switch</strong> statement.
</p>
<p class='vspace'></p><h4>Example</h4>
<pre>
for (x = 0; x &lt; 255; x ++)
{
digitalWrite(PWMpin, x);
sens = analogRead(sensorPin);
if (sens &gt; threshold){ // bail out on sensor detect
x = 0;
break;
}
delay(50);
}
</pre><p><a class='wikilink' href='index.html'>Reference Home</a>
</p>
<p class='vspace'></p><p><em>Corrections, suggestions, and new documentation should be posted to the <a class='urllink' href='http://arduino.cc/forum/index.php/board,23.0.html' rel='nofollow'>Forum</a>.</em>
</p>
<p class='vspace'></p><p>The text of the Arduino reference is licensed under a
<a class='urllink' href='http://creativecommons.org/licenses/by-sa/3.0/' rel='nofollow'>Creative Commons Attribution-ShareAlike 3.0 License</a>. Code samples in the reference are released into the public domain.
</p>
</div>
</div>
<!--PageFooterFmt-->
<div id="pagefooter">
&copy;Arduino |
<a href='#'>Edit Page</a> | <a href='#'>Page History</a> | <a href='#' target='_blank'>Printable View</a> | <a href='http://arduino.cc/en/Site/AllRecentChanges'>All Recent Site Changes</a>
</div>
<!--/PageFooterFmt-->
</div>
</body>
</html>

View File

@@ -0,0 +1,101 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>Arduino Reference - Byte </title>
<link rel="shortcut icon" type="image/x-icon" href="http://arduino.cc/en/favicon.png">
<link rel='stylesheet' href='arduinoWideRender.css'
type='text/css' />
<!--HeaderText--><style type='text/css'><!--
ul, ol, pre, dl, p { margin-top:0px; margin-bottom:0px; }
code { white-space: nowrap; }
.vspace { margin-top:1.33em; }
.indent { margin-left:40px; }
.outdent { margin-left:40px; text-indent:-40px; }
a.createlinktext { text-decoration:none; border-bottom:1px dotted gray; }
a.createlink { text-decoration:none; position:relative; top:-0.5em;
font-weight:bold; font-size:smaller; border-bottom:none; }
img { border:0px; }
.editconflict { color:green;
font-style:italic; margin-top:1.33em; margin-bottom:1.33em; }
table.markup { border: 2px dotted #ccf; width:90%; }
td.markup1, td.markup2 { padding-left:10px; padding-right:10px; }
td.markup1 { border-bottom: 1px solid #ccf; }
div.faq { margin-left:2em; }
div.faq p.question { margin: 1em 0 0.75em -2em; font-weight:bold; }
div.faq hr { margin-left: -2em; }
.frame
{ border:1px solid #cccccc; padding:4px; background-color:#f9f9f9; }
.lfloat { float:left; margin-right:0.5em; }
.rfloat { float:right; margin-left:0.5em; }
a.varlink { text-decoration:none; }
--></style> <meta name='robots' content='index,follow' />
<meta name="verify-v1" content="TtxFIEJAB6zdJ509wLxjnapQzKAMNm9u0Wj4ho6wxIY=" />
</head>
<body>
<div id="page">
<!--PageHeaderFmt-->
<div id="pageheader">
<div class="title"><a href='http://arduino.cc/en'>Arduino</a></div>
</div>
<!--/PageHeaderFmt-->
<!--PageLeftFmt-->
<div id="pagenav">
<div id="navbar">
<p><a class='wikilink' href='http://arduino.cc/en/Main/Buy'>Buy</a>
<a class='wikilink' href='http://arduino.cc/en/Main/Software'>Download</a>
<a class='wikilink' href='Guide_index.html'>Getting Started</a>
<a class='wikilink' href='http://arduino.cc/en/Tutorial/HomePage'>Learning</a>
<a class='wikilink' href='index.html'>Reference</a>
<a class='wikilink' href='http://arduino.cc/en/Main/Hardware'>Hardware</a>
<a class='wikilink' href='FAQ.html'>FAQ</a>
</p>
<p class='vspace'></p>
</div>
</div>
<!--/PageLeftFmt-->
<div id="pagetext">
<!--PageText-->
<div id='wikitext'>
<p><strong>Reference</strong> &nbsp; <a class='wikilink' href='index.html'>Language</a> | <a class='wikilink' href='Libraries.html'>Libraries</a> | <a class='wikilink' href='Comparison.html'>Comparison</a> | <a class='wikilink' href='Changes.html'>Changes</a>
</p>
<p class='vspace'></p><h2>byte</h2>
<h4>Description</h4>
<p>A byte stores an 8-bit unsigned number, from 0 to 255.
</p>
<p class='vspace'></p><h4>Example</h4>
<pre> byte b = B10010; // "B" is the binary formatter (B10010 = 18 decimal)
</pre>
<p class='vspace'></p><h4>See also</h4>
<ul><li><a class='wikilink' href='Word.html'>word</a>
</li><li><a class='wikilink' href='ByteCast.html'>byte</a>()
</li><li><a class='urllink' href='http://arduino.cc/en/Reference/VariableDeclaration' rel='nofollow'>Variable Declaration</a>
</li></ul><p class='vspace'></p><p><a class='wikilink' href='index.html'>Reference Home</a>
</p>
<p class='vspace'></p><p><em>Corrections, suggestions, and new documentation should be posted to the <a class='urllink' href='http://arduino.cc/forum/index.php/board,23.0.html' rel='nofollow'>Forum</a>.</em>
</p>
<p class='vspace'></p><p>The text of the Arduino reference is licensed under a
<a class='urllink' href='http://creativecommons.org/licenses/by-sa/3.0/' rel='nofollow'>Creative Commons Attribution-ShareAlike 3.0 License</a>. Code samples in the reference are released into the public domain.
</p>
</div>
</div>
<!--PageFooterFmt-->
<div id="pagefooter">
&copy;Arduino |
<a href='#'>Edit Page</a> | <a href='#'>Page History</a> | <a href='#' target='_blank'>Printable View</a> | <a href='http://arduino.cc/en/Site/AllRecentChanges'>All Recent Site Changes</a>
</div>
<!--/PageFooterFmt-->
</div>
</body>
</html>

View File

@@ -0,0 +1,105 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>Arduino Reference - ByteCast </title>
<link rel="shortcut icon" type="image/x-icon" href="http://arduino.cc/en/favicon.png">
<link rel='stylesheet' href='arduinoWideRender.css'
type='text/css' />
<!--HeaderText--><style type='text/css'><!--
ul, ol, pre, dl, p { margin-top:0px; margin-bottom:0px; }
code { white-space: nowrap; }
.vspace { margin-top:1.33em; }
.indent { margin-left:40px; }
.outdent { margin-left:40px; text-indent:-40px; }
a.createlinktext { text-decoration:none; border-bottom:1px dotted gray; }
a.createlink { text-decoration:none; position:relative; top:-0.5em;
font-weight:bold; font-size:smaller; border-bottom:none; }
img { border:0px; }
.editconflict { color:green;
font-style:italic; margin-top:1.33em; margin-bottom:1.33em; }
table.markup { border: 2px dotted #ccf; width:90%; }
td.markup1, td.markup2 { padding-left:10px; padding-right:10px; }
td.markup1 { border-bottom: 1px solid #ccf; }
div.faq { margin-left:2em; }
div.faq p.question { margin: 1em 0 0.75em -2em; font-weight:bold; }
div.faq hr { margin-left: -2em; }
.frame
{ border:1px solid #cccccc; padding:4px; background-color:#f9f9f9; }
.lfloat { float:left; margin-right:0.5em; }
.rfloat { float:right; margin-left:0.5em; }
a.varlink { text-decoration:none; }
--></style> <meta name='robots' content='index,follow' />
<meta name="verify-v1" content="TtxFIEJAB6zdJ509wLxjnapQzKAMNm9u0Wj4ho6wxIY=" />
</head>
<body>
<div id="page">
<!--PageHeaderFmt-->
<div id="pageheader">
<div class="title"><a href='http://arduino.cc/en'>Arduino</a></div>
</div>
<!--/PageHeaderFmt-->
<!--PageLeftFmt-->
<div id="pagenav">
<div id="navbar">
<p><a class='wikilink' href='http://arduino.cc/en/Main/Buy'>Buy</a>
<a class='wikilink' href='http://arduino.cc/en/Main/Software'>Download</a>
<a class='wikilink' href='Guide_index.html'>Getting Started</a>
<a class='wikilink' href='http://arduino.cc/en/Tutorial/HomePage'>Learning</a>
<a class='wikilink' href='index.html'>Reference</a>
<a class='wikilink' href='http://arduino.cc/en/Main/Hardware'>Hardware</a>
<a class='wikilink' href='FAQ.html'>FAQ</a>
</p>
<p class='vspace'></p>
</div>
</div>
<!--/PageLeftFmt-->
<div id="pagetext">
<!--PageText-->
<div id='wikitext'>
<p><strong>Reference</strong> &nbsp; <a class='wikilink' href='index.html'>Language</a> | <a class='wikilink' href='Libraries.html'>Libraries</a> | <a class='wikilink' href='Comparison.html'>Comparison</a> | <a class='wikilink' href='Changes.html'>Changes</a>
</p>
<p class='vspace'></p><h2>byte()</h2>
<h4>Description</h4>
<p>Converts a value to the <a class='wikilink' href='Byte.html'>byte</a> data type.
</p>
<p class='vspace'></p><h4>Syntax</h4>
<p>byte(x)
</p>
<p class='vspace'></p><h4>Parameters</h4>
<p>x: a value of any type
</p>
<p class='vspace'></p><h4>Returns</h4>
<p>byte
</p>
<p class='vspace'></p><h4>See also</h4>
<ul><li><a class='wikilink' href='Byte.html'>byte</a>
</li></ul><p><a class='wikilink' href='index.html'>Reference Home</a>
</p>
<p class='vspace'></p><p><em>Corrections, suggestions, and new documentation should be posted to the <a class='urllink' href='http://arduino.cc/forum/index.php/board,23.0.html' rel='nofollow'>Forum</a>.</em>
</p>
<p class='vspace'></p><p>The text of the Arduino reference is licensed under a
<a class='urllink' href='http://creativecommons.org/licenses/by-sa/3.0/' rel='nofollow'>Creative Commons Attribution-ShareAlike 3.0 License</a>. Code samples in the reference are released into the public domain.
</p>
</div>
</div>
<!--PageFooterFmt-->
<div id="pagefooter">
&copy;Arduino |
<a href='#'>Edit Page</a> | <a href='#'>Page History</a> | <a href='#' target='_blank'>Printable View</a> | <a href='http://arduino.cc/en/Site/AllRecentChanges'>All Recent Site Changes</a>
</div>
<!--/PageFooterFmt-->
</div>
</body>
</html>

View File

@@ -0,0 +1,123 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>Arduino Reference - Changes </title>
<link rel="shortcut icon" type="image/x-icon" href="http://arduino.cc/en/favicon.png">
<link rel='stylesheet' href='arduinoWideRender.css'
type='text/css' />
<!--HeaderText--><style type='text/css'><!--
ul, ol, pre, dl, p { margin-top:0px; margin-bottom:0px; }
code { white-space: nowrap; }
.vspace { margin-top:1.33em; }
.indent { margin-left:40px; }
.outdent { margin-left:40px; text-indent:-40px; }
a.createlinktext { text-decoration:none; border-bottom:1px dotted gray; }
a.createlink { text-decoration:none; position:relative; top:-0.5em;
font-weight:bold; font-size:smaller; border-bottom:none; }
img { border:0px; }
.editconflict { color:green;
font-style:italic; margin-top:1.33em; margin-bottom:1.33em; }
table.markup { border: 2px dotted #ccf; width:90%; }
td.markup1, td.markup2 { padding-left:10px; padding-right:10px; }
td.markup1 { border-bottom: 1px solid #ccf; }
div.faq { margin-left:2em; }
div.faq p.question { margin: 1em 0 0.75em -2em; font-weight:bold; }
div.faq hr { margin-left: -2em; }
.frame
{ border:1px solid #cccccc; padding:4px; background-color:#f9f9f9; }
.lfloat { float:left; margin-right:0.5em; }
.rfloat { float:right; margin-left:0.5em; }
a.varlink { text-decoration:none; }
--></style> <meta name='robots' content='index,follow' />
<meta name="verify-v1" content="TtxFIEJAB6zdJ509wLxjnapQzKAMNm9u0Wj4ho6wxIY=" />
</head>
<body>
<div id="page">
<!--PageHeaderFmt-->
<div id="pageheader">
<div class="title"><a href='http://arduino.cc/en'>Arduino</a></div>
</div>
<!--/PageHeaderFmt-->
<!--PageLeftFmt-->
<div id="pagenav">
<div id="navbar">
<p><a class='wikilink' href='http://arduino.cc/en/Main/Buy'>Buy</a>
<a class='wikilink' href='http://arduino.cc/en/Main/Software'>Download</a>
<a class='wikilink' href='Guide_index.html'>Getting Started</a>
<a class='wikilink' href='http://arduino.cc/en/Tutorial/HomePage'>Learning</a>
<a class='wikilink' href='index.html'>Reference</a>
<a class='wikilink' href='http://arduino.cc/en/Main/Hardware'>Hardware</a>
<a class='wikilink' href='FAQ.html'>FAQ</a>
</p>
<p class='vspace'></p>
</div>
</div>
<!--/PageLeftFmt-->
<div id="pagetext">
<!--PageText-->
<div id='wikitext'>
<p><strong>Reference</strong> &nbsp; <a class='wikilink' href='index.html'>Language</a> | <a class='wikilink' href='Libraries.html'>Libraries</a> | <a class='wikilink' href='Comparison.html'>Comparison</a> | <a class='selflink' href='Changes.html'>Changes</a>
</p>
<p class='vspace'></p><h2>Changes</h2>
<p>This page lists major changes to the Arduino core, libraries, and environment. For details, see the <a class='wikilink' href='http://arduino.cc/en/Main/ReleaseNotes'>release notes</a>.
</p>
<p class='vspace'></p><h3>Changes in Arduino 0019</h3>
<ul><li>Added <a class='wikilink' href='StringObject.html'>String</a> class.
<p class='vspace'></p></li><li>Added <a class='wikilink' href='ShiftIn.html'>shiftIn()</a> function.
<p class='vspace'></p></li><li>Added <a class='wikilink' href='Serial_Peek.html'>Serial.peek()</a> function.
<p class='vspace'></p></li><li>Added aliases for the analog input pins: A0, A1, etc.
<p class='vspace'></p></li><li>Added <a class='wikilink' href='SPI.html'>SPI</a> library.
<p class='vspace'></p></li><li>Ethernet library now depends on the SPI library; add <code>#include &lt;SPI.h&gt;</code> to the top of sketches.
</li></ul><p class='vspace'></p><h3>Changes in Arduino 0018</h3>
<ul><li>Added <a class='wikilink' href='Tone.html'>tone()</a> and <a class='wikilink' href='NoTone.html'>noTone()</a> functions.
<p class='vspace'></p></li><li>Added <a class='wikilink' href='Serial_End.html'>Serial.end()</a> function.
<p class='vspace'></p></li><li>Added support for <a class='urllink' href='http://code.google.com/p/arduino/wiki/Platforms' rel='nofollow'>third-party hardware</a> in the hardware sub-directory of the Arduino sketchbook.
</li></ul><p class='vspace'></p><h3>Changes in Arduino 0017</h3>
<ul><li><strong>Environment</strong>: The code base for the Arduino development environment was largely re-written to bring it back into sync with Processing (1.0.3). The main differences include support for multiple sketch windows open simultaneously and a dedicated window for the serial monitor.
<p class='vspace'></p></li><li><strong>Icons</strong>: The icons and about images were updated.
<p class='vspace'></p></li><li><strong>Arduino.app</strong>: The Mac OS X version of Arduino is now a .app file packaged in a .dmg.
<p class='vspace'></p></li><li><strong>Libraries</strong>: Support was added for third-party libraries in the <em>SKETCHBOOK</em>/libraries directory. This allows user-installed libraries to persist across upgrades of the Arduino software.
<p class='vspace'></p></li><li><strong>Servo</strong>: The servo library was rewritten to allow support for up to 12 servos (on any pins) and up to 48 on the Mega.
<p class='vspace'></p></li><li><strong><span class='wikiword'>LiquidCrystal</span></strong>: The begin(), cursor(), noCursor(), blink(), noBlink(), display(), noDisplay(), scrollDisplayLeft(), scrollDisplayRight(), autoscroll(), noAutoscroll(), leftToRight(), rightToLeft(), and createChar() functions were added.
</li></ul><p class='vspace'></p><h3>Changes in Arduino 0016</h3>
<ul><li>New functions for writing a string, write(str), or buffer, write(buf, len), were added to the Print, Serial, and Ethernet library Client and Server classes.
</li></ul><p class='vspace'></p><h3>Changes in Arduino 0015</h3>
<ul><li>Support for the Arduino Mega.
</li></ul><p class='vspace'></p><h3>Changes in Arduino 0013</h3>
<ul><li>Support for printing floats was added to the Print, Serial, and Ethernet library Client and Server classes.
<p class='vspace'></p></li><li>The word type and word(), bitRead(), bitWrite(), bitSet(), bitClear(), bit(), lowByte(), and highByte() functions were added.
</li></ul><p class='vspace'></p><h3>Changes in Arduino 0012</h3>
<ul><li>Added the Firmata library, which provides a standard protocol for serial communication.
<p class='vspace'></p></li><li>Added Ethernet library.
<p class='vspace'></p></li><li>Added Servo library.
<p class='vspace'></p></li><li>Added <span class='wikiword'>LiquidCrystal</span> library.
</li></ul><p><a class='wikilink' href='index.html'>Reference Home</a>
</p>
<p class='vspace'></p><p><em>Corrections, suggestions, and new documentation should be posted to the <a class='urllink' href='http://arduino.cc/forum/index.php/board,23.0.html' rel='nofollow'>Forum</a>.</em>
</p>
<p class='vspace'></p><p>The text of the Arduino reference is licensed under a
<a class='urllink' href='http://creativecommons.org/licenses/by-sa/3.0/' rel='nofollow'>Creative Commons Attribution-ShareAlike 3.0 License</a>. Code samples in the reference are released into the public domain.
</p>
</div>
</div>
<!--PageFooterFmt-->
<div id="pagefooter">
&copy;Arduino |
<a href='#'>Edit Page</a> | <a href='#'>Page History</a> | <a href='#' target='_blank'>Printable View</a> | <a href='http://arduino.cc/en/Site/AllRecentChanges'>All Recent Site Changes</a>
</div>
<!--/PageFooterFmt-->
</div>
</body>
</html>

View File

@@ -0,0 +1,108 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>Arduino Reference - Char </title>
<link rel="shortcut icon" type="image/x-icon" href="http://arduino.cc/en/favicon.png">
<link rel='stylesheet' href='arduinoWideRender.css'
type='text/css' />
<!--HeaderText--><style type='text/css'><!--
ul, ol, pre, dl, p { margin-top:0px; margin-bottom:0px; }
code { white-space: nowrap; }
.vspace { margin-top:1.33em; }
.indent { margin-left:40px; }
.outdent { margin-left:40px; text-indent:-40px; }
a.createlinktext { text-decoration:none; border-bottom:1px dotted gray; }
a.createlink { text-decoration:none; position:relative; top:-0.5em;
font-weight:bold; font-size:smaller; border-bottom:none; }
img { border:0px; }
.editconflict { color:green;
font-style:italic; margin-top:1.33em; margin-bottom:1.33em; }
table.markup { border: 2px dotted #ccf; width:90%; }
td.markup1, td.markup2 { padding-left:10px; padding-right:10px; }
td.markup1 { border-bottom: 1px solid #ccf; }
div.faq { margin-left:2em; }
div.faq p.question { margin: 1em 0 0.75em -2em; font-weight:bold; }
div.faq hr { margin-left: -2em; }
.frame
{ border:1px solid #cccccc; padding:4px; background-color:#f9f9f9; }
.lfloat { float:left; margin-right:0.5em; }
.rfloat { float:right; margin-left:0.5em; }
a.varlink { text-decoration:none; }
--></style> <meta name='robots' content='index,follow' />
<meta name="verify-v1" content="TtxFIEJAB6zdJ509wLxjnapQzKAMNm9u0Wj4ho6wxIY=" />
</head>
<body>
<div id="page">
<!--PageHeaderFmt-->
<div id="pageheader">
<div class="title"><a href='http://arduino.cc/en'>Arduino</a></div>
</div>
<!--/PageHeaderFmt-->
<!--PageLeftFmt-->
<div id="pagenav">
<div id="navbar">
<p><a class='wikilink' href='http://arduino.cc/en/Main/Buy'>Buy</a>
<a class='wikilink' href='http://arduino.cc/en/Main/Software'>Download</a>
<a class='wikilink' href='Guide_index.html'>Getting Started</a>
<a class='wikilink' href='http://arduino.cc/en/Tutorial/HomePage'>Learning</a>
<a class='wikilink' href='index.html'>Reference</a>
<a class='wikilink' href='http://arduino.cc/en/Main/Hardware'>Hardware</a>
<a class='wikilink' href='FAQ.html'>FAQ</a>
</p>
<p class='vspace'></p>
</div>
</div>
<!--/PageLeftFmt-->
<div id="pagetext">
<!--PageText-->
<div id='wikitext'>
<p><strong>Reference</strong> &nbsp; <a class='wikilink' href='index.html'>Language</a> | <a class='wikilink' href='Libraries.html'>Libraries</a> | <a class='wikilink' href='Comparison.html'>Comparison</a> | <a class='wikilink' href='Changes.html'>Changes</a>
</p>
<p class='vspace'></p><h2>char</h2>
<h4>Description</h4>
<p>A data type that takes up 1 byte of memory that stores a character value. Character literals are written in single quotes, like this: 'A' (for multiple characters - strings - use double quotes: "ABC").
</p>
<p class='vspace'></p><p>Characters are stored as numbers however. You can see the specific encoding in the <a class='wikilink' href='ASCIIchart.html'>ASCII chart</a>. This means that it is possible to do arithmetic on characters, in which the ASCII value of the character is used (e.g. 'A' + 1 has the value 66, since the ASCII value of the capital letter A is 65). See <a class='wikilink' href='Serial_Println.html'>Serial.println</a> reference for more on how characters are translated to numbers.
</p>
<p class='vspace'></p><p>The char datatype is a signed type, meaning that it encodes numbers from -128 to 127. For an unsigned, one-byte (8 bit) data type, use the <em>byte</em> data type.
</p>
<p class='vspace'></p><h4>Example</h4>
<pre> char myChar = 'A';
char myChar = 65; // both are equivalent
</pre>
<p class='vspace'></p><h4>See also</h4>
<ul><li><a class='wikilink' href='Byte.html'>byte</a>
</li><li><a class='wikilink' href='Int.html'>int</a>
</li><li><a class='wikilink' href='Array.html'>array</a>
</li><li><a class='wikilink' href='Serial_Println.html'>Serial.println</a>
</li></ul><p><a class='wikilink' href='index.html'>Reference Home</a>
</p>
<p class='vspace'></p><p><em>Corrections, suggestions, and new documentation should be posted to the <a class='urllink' href='http://arduino.cc/forum/index.php/board,23.0.html' rel='nofollow'>Forum</a>.</em>
</p>
<p class='vspace'></p><p>The text of the Arduino reference is licensed under a
<a class='urllink' href='http://creativecommons.org/licenses/by-sa/3.0/' rel='nofollow'>Creative Commons Attribution-ShareAlike 3.0 License</a>. Code samples in the reference are released into the public domain.
</p>
</div>
</div>
<!--PageFooterFmt-->
<div id="pagefooter">
&copy;Arduino |
<a href='#'>Edit Page</a> | <a href='#'>Page History</a> | <a href='#' target='_blank'>Printable View</a> | <a href='http://arduino.cc/en/Site/AllRecentChanges'>All Recent Site Changes</a>
</div>
<!--/PageFooterFmt-->
</div>
</body>
</html>

View File

@@ -0,0 +1,105 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>Arduino Reference - CharCast </title>
<link rel="shortcut icon" type="image/x-icon" href="http://arduino.cc/en/favicon.png">
<link rel='stylesheet' href='arduinoWideRender.css'
type='text/css' />
<!--HeaderText--><style type='text/css'><!--
ul, ol, pre, dl, p { margin-top:0px; margin-bottom:0px; }
code { white-space: nowrap; }
.vspace { margin-top:1.33em; }
.indent { margin-left:40px; }
.outdent { margin-left:40px; text-indent:-40px; }
a.createlinktext { text-decoration:none; border-bottom:1px dotted gray; }
a.createlink { text-decoration:none; position:relative; top:-0.5em;
font-weight:bold; font-size:smaller; border-bottom:none; }
img { border:0px; }
.editconflict { color:green;
font-style:italic; margin-top:1.33em; margin-bottom:1.33em; }
table.markup { border: 2px dotted #ccf; width:90%; }
td.markup1, td.markup2 { padding-left:10px; padding-right:10px; }
td.markup1 { border-bottom: 1px solid #ccf; }
div.faq { margin-left:2em; }
div.faq p.question { margin: 1em 0 0.75em -2em; font-weight:bold; }
div.faq hr { margin-left: -2em; }
.frame
{ border:1px solid #cccccc; padding:4px; background-color:#f9f9f9; }
.lfloat { float:left; margin-right:0.5em; }
.rfloat { float:right; margin-left:0.5em; }
a.varlink { text-decoration:none; }
--></style> <meta name='robots' content='index,follow' />
<meta name="verify-v1" content="TtxFIEJAB6zdJ509wLxjnapQzKAMNm9u0Wj4ho6wxIY=" />
</head>
<body>
<div id="page">
<!--PageHeaderFmt-->
<div id="pageheader">
<div class="title"><a href='http://arduino.cc/en'>Arduino</a></div>
</div>
<!--/PageHeaderFmt-->
<!--PageLeftFmt-->
<div id="pagenav">
<div id="navbar">
<p><a class='wikilink' href='http://arduino.cc/en/Main/Buy'>Buy</a>
<a class='wikilink' href='http://arduino.cc/en/Main/Software'>Download</a>
<a class='wikilink' href='Guide_index.html'>Getting Started</a>
<a class='wikilink' href='http://arduino.cc/en/Tutorial/HomePage'>Learning</a>
<a class='wikilink' href='index.html'>Reference</a>
<a class='wikilink' href='http://arduino.cc/en/Main/Hardware'>Hardware</a>
<a class='wikilink' href='FAQ.html'>FAQ</a>
</p>
<p class='vspace'></p>
</div>
</div>
<!--/PageLeftFmt-->
<div id="pagetext">
<!--PageText-->
<div id='wikitext'>
<p><strong>Reference</strong> &nbsp; <a class='wikilink' href='index.html'>Language</a> | <a class='wikilink' href='Libraries.html'>Libraries</a> | <a class='wikilink' href='Comparison.html'>Comparison</a> | <a class='wikilink' href='Changes.html'>Changes</a>
</p>
<p class='vspace'></p><h2>char()</h2>
<h4>Description</h4>
<p>Converts a value to the <a class='wikilink' href='Char.html'>char</a> data type.
</p>
<p class='vspace'></p><h4>Syntax</h4>
<p>char(x)
</p>
<p class='vspace'></p><h4>Parameters</h4>
<p>x: a value of any type
</p>
<p class='vspace'></p><h4>Returns</h4>
<p>char
</p>
<p class='vspace'></p><h4>See also</h4>
<ul><li><a class='wikilink' href='Char.html'>char</a>
</li></ul><p><a class='wikilink' href='index.html'>Reference Home</a>
</p>
<p class='vspace'></p><p><em>Corrections, suggestions, and new documentation should be posted to the <a class='urllink' href='http://arduino.cc/forum/index.php/board,23.0.html' rel='nofollow'>Forum</a>.</em>
</p>
<p class='vspace'></p><p>The text of the Arduino reference is licensed under a
<a class='urllink' href='http://creativecommons.org/licenses/by-sa/3.0/' rel='nofollow'>Creative Commons Attribution-ShareAlike 3.0 License</a>. Code samples in the reference are released into the public domain.
</p>
</div>
</div>
<!--PageFooterFmt-->
<div id="pagefooter">
&copy;Arduino |
<a href='#'>Edit Page</a> | <a href='#'>Page History</a> | <a href='#' target='_blank'>Printable View</a> | <a href='http://arduino.cc/en/Site/AllRecentChanges'>All Recent Site Changes</a>
</div>
<!--/PageFooterFmt-->
</div>
</body>
</html>

View File

@@ -0,0 +1,209 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>Arduino Reference - ClientAvailable </title>
<link rel="shortcut icon" type="image/x-icon" href="http://arduino.cc/en/favicon.png">
<link rel='stylesheet' href='arduinoWideRender.css'
type='text/css' />
<!--HeaderText--><style type='text/css'><!--
ul, ol, pre, dl, p { margin-top:0px; margin-bottom:0px; }
code { white-space: nowrap; }
.vspace { margin-top:1.33em; }
.indent { margin-left:40px; }
.outdent { margin-left:40px; text-indent:-40px; }
a.createlinktext { text-decoration:none; border-bottom:1px dotted gray; }
a.createlink { text-decoration:none; position:relative; top:-0.5em;
font-weight:bold; font-size:smaller; border-bottom:none; }
img { border:0px; }
.editconflict { color:green;
font-style:italic; margin-top:1.33em; margin-bottom:1.33em; }
table.markup { border: 2px dotted #ccf; width:90%; }
td.markup1, td.markup2 { padding-left:10px; padding-right:10px; }
td.markup1 { border-bottom: 1px solid #ccf; }
div.faq { margin-left:2em; }
div.faq p.question { margin: 1em 0 0.75em -2em; font-weight:bold; }
div.faq hr { margin-left: -2em; }
.frame
{ border:1px solid #cccccc; padding:4px; background-color:#f9f9f9; }
.lfloat { float:left; margin-right:0.5em; }
.rfloat { float:right; margin-left:0.5em; }
a.varlink { text-decoration:none; }
/**
* GeSHi (C) 2004 - 2007 Nigel McNie, 2007 - 2008 Benny Baumann
* (http://qbnz.com/highlighter/ and http://geshi.org/)
*/
.arduino {font-family:monospace;}
.arduino .imp {font-weight: bold; color: red;}
.arduino .kw1 {color: #CC6600;}
.arduino .kw2 {color: #006699;}
.arduino .kw3 {color: #CC6600; font-weight: bold;}
.arduino .co1 {color: #7E7E7E; font-style: italic;}
.arduino .co2 {color: #7E7E7E;}
.arduino .coMULTI {color: #7E7E7E; font-style: italic;}
.arduino .es0 {color: #000099; font-weight: bold;}
.arduino .es1 {color: #000099; font-weight: bold;}
.arduino .es2 {color: #660099; font-weight: bold;}
.arduino .es3 {color: #660099; font-weight: bold;}
.arduino .es4 {color: #660099; font-weight: bold;}
.arduino .es5 {color: #006699; font-weight: bold;}
.arduino .br0 {color: #000000;}
.arduino .sy0 {color: #000000;}
.arduino .st0 {color: #0066CC;}
.arduino .nu0 {color: #000000;}
.arduino .nu6 {color: #208080;}
.arduino .nu8 {color: #208080;}
.arduino .nu12 {color: #208080;}
.arduino .nu16 {color:#800080;}
.arduino .nu17 {color:#800080;}
.arduino .nu18 {color:#800080;}
.arduino .nu19 {color:#800080;}
.arduino .me1 {color: #ff1493;}
.arduino .me2 {color: #ff1493;}
.arduino span.xtra { display:block; }
.sourceblocklink {
text-align: right;
font-size: smaller;
}
.sourceblocktext {
padding: 0.5em;
color: #000000;
background-color: #ffffff;
}
.sourceblocktext div {
font-family: monospace;
font-size: small;
line-height: 1;
height: 1%;
}
.sourceblocktext div.head,
.sourceblocktext div.foot {
font: italic medium serif;
padding: 0.5em;
}
--></style> <meta name='robots' content='index,follow' />
<meta name="verify-v1" content="TtxFIEJAB6zdJ509wLxjnapQzKAMNm9u0Wj4ho6wxIY=" />
</head>
<body>
<div id="page">
<!--PageHeaderFmt-->
<div id="pageheader">
<div class="title"><a href='http://arduino.cc/en'>Arduino</a></div>
</div>
<!--/PageHeaderFmt-->
<!--PageLeftFmt-->
<div id="pagenav">
<div id="navbar">
<p><a class='wikilink' href='http://arduino.cc/en/Main/Buy'>Buy</a>
<a class='wikilink' href='http://arduino.cc/en/Main/Software'>Download</a>
<a class='wikilink' href='Guide_index.html'>Getting Started</a>
<a class='wikilink' href='http://arduino.cc/en/Tutorial/HomePage'>Learning</a>
<a class='wikilink' href='index.html'>Reference</a>
<a class='wikilink' href='http://arduino.cc/en/Main/Hardware'>Hardware</a>
<a class='wikilink' href='FAQ.html'>FAQ</a>
</p>
<p class='vspace'></p>
</div>
</div>
<!--/PageLeftFmt-->
<div id="pagetext">
<!--PageText-->
<div id='wikitext'>
<p><strong>Reference</strong> &nbsp; <a class='wikilink' href='index.html'>Language</a> | <a class='wikilink' href='Libraries.html'>Libraries</a> | <a class='wikilink' href='Comparison.html'>Comparison</a> | <a class='wikilink' href='Changes.html'>Changes</a>
</p>
<p class='vspace'></p><p><a class='wikilink' href='Ethernet.html'>Ethernet</a> : <em>Client</em> class
</p>
<p class='vspace'></p><h2>available()</h2>
<h4>Description</h4>
<p>Returns the number of bytes available for reading (that is, the amount of data that has been written to the client by the server it is connected to).
</p>
<p class='vspace'></p><p>available() inherits from the <a class='wikilink' href='Stream.html'>Stream</a> utility class.
</p>
<p class='vspace'></p><h4>Syntax</h4>
<p><em>client</em>.available()
</p>
<p class='vspace'></p><h4>Parameters</h4>
<p>none
</p>
<p class='vspace'></p><h4>Returns</h4>
<p>The number of bytes available.
</p>
<p class='vspace'></p><h4>Example</h4>
<p>
<div class='sourceblock ' id='sourceblock1'>
<div class='sourceblocktext'><div class="arduino"><span class="co2">#include &lt;Ethernet.h&gt;</span><br />
<span class="co2">#include &lt;SPI.h&gt;</span><br />
<br />
<span class="kw1">byte</span> mac<span class="br0">&#91;</span><span class="br0">&#93;</span> <span class="sy0">=</span> <span class="br0">&#123;</span> <span class="nu12">0xDE</span><span class="sy0">,</span> <span class="nu12">0xAD</span><span class="sy0">,</span> <span class="nu12">0xBE</span><span class="sy0">,</span> <span class="nu12">0xEF</span><span class="sy0">,</span> <span class="nu12">0xFE</span><span class="sy0">,</span> <span class="nu12">0xED</span> <span class="br0">&#125;</span><span class="sy0">;</span><br />
<span class="kw1">byte</span> ip<span class="br0">&#91;</span><span class="br0">&#93;</span> <span class="sy0">=</span> <span class="br0">&#123;</span> <span class="nu0">10</span><span class="sy0">,</span> <span class="nu0">0</span><span class="sy0">,</span> <span class="nu0">0</span><span class="sy0">,</span> <span class="nu0">177</span> <span class="br0">&#125;</span><span class="sy0">;</span><br />
<span class="kw1">byte</span> server<span class="br0">&#91;</span><span class="br0">&#93;</span> <span class="sy0">=</span> <span class="br0">&#123;</span> <span class="nu0">64</span><span class="sy0">,</span> <span class="nu0">233</span><span class="sy0">,</span> <span class="nu0">187</span><span class="sy0">,</span> <span class="nu0">99</span> <span class="br0">&#125;</span><span class="sy0">;</span> <span class="co1">// Google</span><br />
<br />
EthernetClient client<span class="sy0">;</span><br />
<br />
<span class="kw1">void</span> <span class="kw3">setup</span><span class="br0">&#40;</span><span class="br0">&#41;</span><br />
<span class="br0">&#123;</span><br />
&nbsp; Ethernet.<span class="kw1">begin</span><span class="br0">&#40;</span>mac<span class="sy0">,</span> ip<span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; <span class="kw1">Serial</span>.<span class="kw1">begin</span><span class="br0">&#40;</span><span class="nu0">9600</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
<br />
&nbsp; <span class="kw1">delay</span><span class="br0">&#40;</span><span class="nu0">1000</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
<br />
&nbsp; <span class="kw1">Serial</span>.<span class="kw1">println</span><span class="br0">&#40;</span><span class="st0">&quot;connecting...&quot;</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
<br />
&nbsp; <span class="kw1">if</span> <span class="br0">&#40;</span>client.<span class="kw1">connect</span><span class="br0">&#40;</span>server<span class="sy0">,</span> <span class="nu0">80</span><span class="br0">&#41;</span><span class="br0">&#41;</span> <span class="br0">&#123;</span><br />
&nbsp; &nbsp; <span class="kw1">Serial</span>.<span class="kw1">println</span><span class="br0">&#40;</span><span class="st0">&quot;connected&quot;</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; client.<span class="kw1">println</span><span class="br0">&#40;</span><span class="st0">&quot;GET /search?q=arduino HTTP/1.0&quot;</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; client.<span class="kw1">println</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; <span class="br0">&#125;</span> <span class="kw1">else</span> <span class="br0">&#123;</span><br />
&nbsp; &nbsp; <span class="kw1">Serial</span>.<span class="kw1">println</span><span class="br0">&#40;</span><span class="st0">&quot;connection failed&quot;</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; <span class="br0">&#125;</span><br />
<span class="br0">&#125;</span><br />
<br />
<span class="kw1">void</span> <span class="kw3">loop</span><span class="br0">&#40;</span><span class="br0">&#41;</span><br />
<span class="br0">&#123;</span><br />
&nbsp; <span class="kw1">if</span> <span class="br0">&#40;</span>client.<span class="kw1">available</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="br0">&#41;</span> <span class="br0">&#123;</span><br />
&nbsp; &nbsp; <span class="kw1">char</span> c <span class="sy0">=</span> client.<span class="kw1">read</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; <span class="kw1">Serial</span>.<span class="kw1">print</span><span class="br0">&#40;</span>c<span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; <span class="br0">&#125;</span><br />
<br />
&nbsp; <span class="kw1">if</span> <span class="br0">&#40;</span><span class="sy0">!</span>client.<span class="kw1">connected</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="br0">&#41;</span> <span class="br0">&#123;</span><br />
&nbsp; &nbsp; <span class="kw1">Serial</span>.<span class="kw1">println</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; <span class="kw1">Serial</span>.<span class="kw1">println</span><span class="br0">&#40;</span><span class="st0">&quot;disconnecting.&quot;</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; client.<span class="kw1">stop</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; <span class="kw1">for</span><span class="br0">&#40;</span><span class="sy0">;;</span><span class="br0">&#41;</span><br />
&nbsp; &nbsp; &nbsp; <span class="sy0">;</span><br />
&nbsp; <span class="br0">&#125;</span><br />
<span class="br0">&#125;</span></div></div>
<div class='sourceblocklink'><a href='#' type='text/plain'>[Get Code]</a></div>
</div>
</p>
<p class='vspace'></p><h4>See also</h4>
<ul><li><a class='wikilink' href='StreamAvailable.html'>Stream.available()</a><br /><br /><a class='wikilink' href='index.html'>Reference Home</a>
</li></ul><p class='vspace'></p><p><em>Corrections, suggestions, and new documentation should be posted to the <a class='urllink' href='http://arduino.cc/forum/index.php/board,23.0.html' rel='nofollow'>Forum</a>.</em>
</p>
<p class='vspace'></p><p>The text of the Arduino reference is licensed under a
<a class='urllink' href='http://creativecommons.org/licenses/by-sa/3.0/' rel='nofollow'>Creative Commons Attribution-ShareAlike 3.0 License</a>. Code samples in the reference are released into the public domain.
</p>
</div>
</div>
<!--PageFooterFmt-->
<div id="pagefooter">
&copy;Arduino |
<a href='#'>Edit Page</a> | <a href='#'>Page History</a> | <a href='#' target='_blank'>Printable View</a> | <a href='http://arduino.cc/en/Site/AllRecentChanges'>All Recent Site Changes</a>
</div>
<!--/PageFooterFmt-->
</div>
</body>
</html>

View File

@@ -0,0 +1,211 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>Arduino Reference - ClientConnect </title>
<link rel="shortcut icon" type="image/x-icon" href="http://arduino.cc/en/favicon.png">
<link rel='stylesheet' href='arduinoWideRender.css'
type='text/css' />
<!--HeaderText--><style type='text/css'><!--
ul, ol, pre, dl, p { margin-top:0px; margin-bottom:0px; }
code { white-space: nowrap; }
.vspace { margin-top:1.33em; }
.indent { margin-left:40px; }
.outdent { margin-left:40px; text-indent:-40px; }
a.createlinktext { text-decoration:none; border-bottom:1px dotted gray; }
a.createlink { text-decoration:none; position:relative; top:-0.5em;
font-weight:bold; font-size:smaller; border-bottom:none; }
img { border:0px; }
.editconflict { color:green;
font-style:italic; margin-top:1.33em; margin-bottom:1.33em; }
table.markup { border: 2px dotted #ccf; width:90%; }
td.markup1, td.markup2 { padding-left:10px; padding-right:10px; }
td.markup1 { border-bottom: 1px solid #ccf; }
div.faq { margin-left:2em; }
div.faq p.question { margin: 1em 0 0.75em -2em; font-weight:bold; }
div.faq hr { margin-left: -2em; }
.frame
{ border:1px solid #cccccc; padding:4px; background-color:#f9f9f9; }
.lfloat { float:left; margin-right:0.5em; }
.rfloat { float:right; margin-left:0.5em; }
a.varlink { text-decoration:none; }
/**
* GeSHi (C) 2004 - 2007 Nigel McNie, 2007 - 2008 Benny Baumann
* (http://qbnz.com/highlighter/ and http://geshi.org/)
*/
.arduino {font-family:monospace;}
.arduino .imp {font-weight: bold; color: red;}
.arduino .kw1 {color: #CC6600;}
.arduino .kw2 {color: #006699;}
.arduino .kw3 {color: #CC6600; font-weight: bold;}
.arduino .co1 {color: #7E7E7E; font-style: italic;}
.arduino .co2 {color: #7E7E7E;}
.arduino .coMULTI {color: #7E7E7E; font-style: italic;}
.arduino .es0 {color: #000099; font-weight: bold;}
.arduino .es1 {color: #000099; font-weight: bold;}
.arduino .es2 {color: #660099; font-weight: bold;}
.arduino .es3 {color: #660099; font-weight: bold;}
.arduino .es4 {color: #660099; font-weight: bold;}
.arduino .es5 {color: #006699; font-weight: bold;}
.arduino .br0 {color: #000000;}
.arduino .sy0 {color: #000000;}
.arduino .st0 {color: #0066CC;}
.arduino .nu0 {color: #000000;}
.arduino .nu6 {color: #208080;}
.arduino .nu8 {color: #208080;}
.arduino .nu12 {color: #208080;}
.arduino .nu16 {color:#800080;}
.arduino .nu17 {color:#800080;}
.arduino .nu18 {color:#800080;}
.arduino .nu19 {color:#800080;}
.arduino .me1 {color: #ff1493;}
.arduino .me2 {color: #ff1493;}
.arduino span.xtra { display:block; }
.sourceblocklink {
text-align: right;
font-size: smaller;
}
.sourceblocktext {
padding: 0.5em;
color: #000000;
background-color: #ffffff;
}
.sourceblocktext div {
font-family: monospace;
font-size: small;
line-height: 1;
height: 1%;
}
.sourceblocktext div.head,
.sourceblocktext div.foot {
font: italic medium serif;
padding: 0.5em;
}
--></style> <meta name='robots' content='index,follow' />
<meta name="verify-v1" content="TtxFIEJAB6zdJ509wLxjnapQzKAMNm9u0Wj4ho6wxIY=" />
</head>
<body>
<div id="page">
<!--PageHeaderFmt-->
<div id="pageheader">
<div class="title"><a href='http://arduino.cc/en'>Arduino</a></div>
</div>
<!--/PageHeaderFmt-->
<!--PageLeftFmt-->
<div id="pagenav">
<div id="navbar">
<p><a class='wikilink' href='http://arduino.cc/en/Main/Buy'>Buy</a>
<a class='wikilink' href='http://arduino.cc/en/Main/Software'>Download</a>
<a class='wikilink' href='Guide_index.html'>Getting Started</a>
<a class='wikilink' href='http://arduino.cc/en/Tutorial/HomePage'>Learning</a>
<a class='wikilink' href='index.html'>Reference</a>
<a class='wikilink' href='http://arduino.cc/en/Main/Hardware'>Hardware</a>
<a class='wikilink' href='FAQ.html'>FAQ</a>
</p>
<p class='vspace'></p>
</div>
</div>
<!--/PageLeftFmt-->
<div id="pagetext">
<!--PageText-->
<div id='wikitext'>
<p><strong>Reference</strong> &nbsp; <a class='wikilink' href='index.html'>Language</a> | <a class='wikilink' href='Libraries.html'>Libraries</a> | <a class='wikilink' href='Comparison.html'>Comparison</a> | <a class='wikilink' href='Changes.html'>Changes</a>
</p>
<p class='vspace'></p><p><a class='wikilink' href='Ethernet.html'>Ethernet</a> : <em>Client</em> class
</p>
<p class='vspace'></p><h2>connect()</h2>
<h4>Description</h4>
<p>Connects to a specified IP address and port. The return value indicates success or failure. Also supports DNS lookups when using a domain name.
</p>
<p class='vspace'></p><h4>Syntax</h4>
<p><em>client</em>.connect(ip, port)<br /><em>client</em>.connect(URL, port)
</p>
<p class='vspace'></p><h4>Parameters</h4>
<p>ip: the IP address that the client will connect to (array of 4 bytes)
</p>
<p class='vspace'></p><p>URL: the domain name the client will connect to (string, ex.:"arduino.cc")
</p>
<p class='vspace'></p><p>port: the port that the client will connect to (int)
</p>
<p class='vspace'></p><h4>Returns</h4>
<p>Returns true if the connection succeeds, false if not.
</p>
<p class='vspace'></p><h4>Example</h4>
<p>
<div class='sourceblock ' id='sourceblock1'>
<div class='sourceblocktext'><div class="arduino"><span class="co2">#include &lt;Ethernet.h&gt;</span><br />
<span class="co2">#include &lt;SPI.h&gt;</span><br />
<br />
<span class="kw1">byte</span> mac<span class="br0">&#91;</span><span class="br0">&#93;</span> <span class="sy0">=</span> <span class="br0">&#123;</span> <span class="nu12">0xDE</span><span class="sy0">,</span> <span class="nu12">0xAD</span><span class="sy0">,</span> <span class="nu12">0xBE</span><span class="sy0">,</span> <span class="nu12">0xEF</span><span class="sy0">,</span> <span class="nu12">0xFE</span><span class="sy0">,</span> <span class="nu12">0xED</span> <span class="br0">&#125;</span><span class="sy0">;</span><br />
<span class="kw1">byte</span> ip<span class="br0">&#91;</span><span class="br0">&#93;</span> <span class="sy0">=</span> <span class="br0">&#123;</span> <span class="nu0">10</span><span class="sy0">,</span> <span class="nu0">0</span><span class="sy0">,</span> <span class="nu0">0</span><span class="sy0">,</span> <span class="nu0">177</span> <span class="br0">&#125;</span><span class="sy0">;</span><br />
<span class="kw1">byte</span> server<span class="br0">&#91;</span><span class="br0">&#93;</span> <span class="sy0">=</span> <span class="br0">&#123;</span> <span class="nu0">64</span><span class="sy0">,</span> <span class="nu0">233</span><span class="sy0">,</span> <span class="nu0">187</span><span class="sy0">,</span> <span class="nu0">99</span> <span class="br0">&#125;</span><span class="sy0">;</span> <span class="co1">// Google</span><br />
<br />
EthernetClient client<span class="sy0">;</span><br />
<br />
<span class="kw1">void</span> <span class="kw3">setup</span><span class="br0">&#40;</span><span class="br0">&#41;</span><br />
<span class="br0">&#123;</span><br />
&nbsp; Ethernet.<span class="kw1">begin</span><span class="br0">&#40;</span>mac<span class="sy0">,</span> ip<span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; <span class="kw1">Serial</span>.<span class="kw1">begin</span><span class="br0">&#40;</span><span class="nu0">9600</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
<br />
&nbsp; <span class="kw1">delay</span><span class="br0">&#40;</span><span class="nu0">1000</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
<br />
&nbsp; <span class="kw1">Serial</span>.<span class="kw1">println</span><span class="br0">&#40;</span><span class="st0">&quot;connecting...&quot;</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
<br />
&nbsp; <span class="kw1">if</span> <span class="br0">&#40;</span>client.<span class="kw1">connect</span><span class="br0">&#40;</span>server<span class="sy0">,</span> <span class="nu0">80</span><span class="br0">&#41;</span><span class="br0">&#41;</span> <span class="br0">&#123;</span><br />
&nbsp; &nbsp; <span class="kw1">Serial</span>.<span class="kw1">println</span><span class="br0">&#40;</span><span class="st0">&quot;connected&quot;</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; client.<span class="kw1">println</span><span class="br0">&#40;</span><span class="st0">&quot;GET /search?q=arduino HTTP/1.0&quot;</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; client.<span class="kw1">println</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; <span class="br0">&#125;</span> <span class="kw1">else</span> <span class="br0">&#123;</span><br />
&nbsp; &nbsp; <span class="kw1">Serial</span>.<span class="kw1">println</span><span class="br0">&#40;</span><span class="st0">&quot;connection failed&quot;</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; <span class="br0">&#125;</span><br />
<span class="br0">&#125;</span><br />
<br />
<span class="kw1">void</span> <span class="kw3">loop</span><span class="br0">&#40;</span><span class="br0">&#41;</span><br />
<span class="br0">&#123;</span><br />
&nbsp; <span class="kw1">if</span> <span class="br0">&#40;</span>client.<span class="kw1">available</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="br0">&#41;</span> <span class="br0">&#123;</span><br />
&nbsp; &nbsp; <span class="kw1">char</span> c <span class="sy0">=</span> client.<span class="kw1">read</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; <span class="kw1">Serial</span>.<span class="kw1">print</span><span class="br0">&#40;</span>c<span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; <span class="br0">&#125;</span><br />
<br />
&nbsp; <span class="kw1">if</span> <span class="br0">&#40;</span><span class="sy0">!</span>client.<span class="kw1">connected</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="br0">&#41;</span> <span class="br0">&#123;</span><br />
&nbsp; &nbsp; <span class="kw1">Serial</span>.<span class="kw1">println</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; <span class="kw1">Serial</span>.<span class="kw1">println</span><span class="br0">&#40;</span><span class="st0">&quot;disconnecting.&quot;</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; client.<span class="kw1">stop</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; <span class="kw1">for</span><span class="br0">&#40;</span><span class="sy0">;;</span><span class="br0">&#41;</span><br />
&nbsp; &nbsp; &nbsp; <span class="sy0">;</span><br />
&nbsp; <span class="br0">&#125;</span><br />
<span class="br0">&#125;</span></div></div>
<div class='sourceblocklink'><a href='#' type='text/plain'>[Get Code]</a></div>
</div>
</p>
<p class='vspace'></p><p><a class='wikilink' href='index.html'>Reference Home</a>
</p>
<p class='vspace'></p><p><em>Corrections, suggestions, and new documentation should be posted to the <a class='urllink' href='http://arduino.cc/forum/index.php/board,23.0.html' rel='nofollow'>Forum</a>.</em>
</p>
<p class='vspace'></p><p>The text of the Arduino reference is licensed under a
<a class='urllink' href='http://creativecommons.org/licenses/by-sa/3.0/' rel='nofollow'>Creative Commons Attribution-ShareAlike 3.0 License</a>. Code samples in the reference are released into the public domain.
</p>
</div>
</div>
<!--PageFooterFmt-->
<div id="pagefooter">
&copy;Arduino |
<a href='#'>Edit Page</a> | <a href='#'>Page History</a> | <a href='#' target='_blank'>Printable View</a> | <a href='http://arduino.cc/en/Site/AllRecentChanges'>All Recent Site Changes</a>
</div>
<!--/PageFooterFmt-->
</div>
</body>
</html>

View File

@@ -0,0 +1,207 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>Arduino Reference - ClientConnected </title>
<link rel="shortcut icon" type="image/x-icon" href="http://arduino.cc/en/favicon.png">
<link rel='stylesheet' href='arduinoWideRender.css'
type='text/css' />
<!--HeaderText--><style type='text/css'><!--
ul, ol, pre, dl, p { margin-top:0px; margin-bottom:0px; }
code { white-space: nowrap; }
.vspace { margin-top:1.33em; }
.indent { margin-left:40px; }
.outdent { margin-left:40px; text-indent:-40px; }
a.createlinktext { text-decoration:none; border-bottom:1px dotted gray; }
a.createlink { text-decoration:none; position:relative; top:-0.5em;
font-weight:bold; font-size:smaller; border-bottom:none; }
img { border:0px; }
.editconflict { color:green;
font-style:italic; margin-top:1.33em; margin-bottom:1.33em; }
table.markup { border: 2px dotted #ccf; width:90%; }
td.markup1, td.markup2 { padding-left:10px; padding-right:10px; }
td.markup1 { border-bottom: 1px solid #ccf; }
div.faq { margin-left:2em; }
div.faq p.question { margin: 1em 0 0.75em -2em; font-weight:bold; }
div.faq hr { margin-left: -2em; }
.frame
{ border:1px solid #cccccc; padding:4px; background-color:#f9f9f9; }
.lfloat { float:left; margin-right:0.5em; }
.rfloat { float:right; margin-left:0.5em; }
a.varlink { text-decoration:none; }
/**
* GeSHi (C) 2004 - 2007 Nigel McNie, 2007 - 2008 Benny Baumann
* (http://qbnz.com/highlighter/ and http://geshi.org/)
*/
.arduino {font-family:monospace;}
.arduino .imp {font-weight: bold; color: red;}
.arduino .kw1 {color: #CC6600;}
.arduino .kw2 {color: #006699;}
.arduino .kw3 {color: #CC6600; font-weight: bold;}
.arduino .co1 {color: #7E7E7E; font-style: italic;}
.arduino .co2 {color: #7E7E7E;}
.arduino .coMULTI {color: #7E7E7E; font-style: italic;}
.arduino .es0 {color: #000099; font-weight: bold;}
.arduino .es1 {color: #000099; font-weight: bold;}
.arduino .es2 {color: #660099; font-weight: bold;}
.arduino .es3 {color: #660099; font-weight: bold;}
.arduino .es4 {color: #660099; font-weight: bold;}
.arduino .es5 {color: #006699; font-weight: bold;}
.arduino .br0 {color: #000000;}
.arduino .sy0 {color: #000000;}
.arduino .st0 {color: #0066CC;}
.arduino .nu0 {color: #000000;}
.arduino .nu6 {color: #208080;}
.arduino .nu8 {color: #208080;}
.arduino .nu12 {color: #208080;}
.arduino .nu16 {color:#800080;}
.arduino .nu17 {color:#800080;}
.arduino .nu18 {color:#800080;}
.arduino .nu19 {color:#800080;}
.arduino .me1 {color: #ff1493;}
.arduino .me2 {color: #ff1493;}
.arduino span.xtra { display:block; }
.sourceblocklink {
text-align: right;
font-size: smaller;
}
.sourceblocktext {
padding: 0.5em;
color: #000000;
background-color: #ffffff;
}
.sourceblocktext div {
font-family: monospace;
font-size: small;
line-height: 1;
height: 1%;
}
.sourceblocktext div.head,
.sourceblocktext div.foot {
font: italic medium serif;
padding: 0.5em;
}
--></style> <meta name='robots' content='index,follow' />
<meta name="verify-v1" content="TtxFIEJAB6zdJ509wLxjnapQzKAMNm9u0Wj4ho6wxIY=" />
</head>
<body>
<div id="page">
<!--PageHeaderFmt-->
<div id="pageheader">
<div class="title"><a href='http://arduino.cc/en'>Arduino</a></div>
</div>
<!--/PageHeaderFmt-->
<!--PageLeftFmt-->
<div id="pagenav">
<div id="navbar">
<p><a class='wikilink' href='http://arduino.cc/en/Main/Buy'>Buy</a>
<a class='wikilink' href='http://arduino.cc/en/Main/Software'>Download</a>
<a class='wikilink' href='Guide_index.html'>Getting Started</a>
<a class='wikilink' href='http://arduino.cc/en/Tutorial/HomePage'>Learning</a>
<a class='wikilink' href='index.html'>Reference</a>
<a class='wikilink' href='http://arduino.cc/en/Main/Hardware'>Hardware</a>
<a class='wikilink' href='FAQ.html'>FAQ</a>
</p>
<p class='vspace'></p>
</div>
</div>
<!--/PageLeftFmt-->
<div id="pagetext">
<!--PageText-->
<div id='wikitext'>
<p><strong>Reference</strong> &nbsp; <a class='wikilink' href='index.html'>Language</a> | <a class='wikilink' href='Libraries.html'>Libraries</a> | <a class='wikilink' href='Comparison.html'>Comparison</a> | <a class='wikilink' href='Changes.html'>Changes</a>
</p>
<p class='vspace'></p><p><a class='wikilink' href='Ethernet.html'>Ethernet</a> : <em>Client</em> class
</p>
<p class='vspace'></p><h2>connected()</h2>
<h4>Description</h4>
<p>Whether or not the client is connected. Note that a client is considered connected if the connection has been closed but there is still unread data.
</p>
<p class='vspace'></p><h4>Syntax</h4>
<p><em>client</em>.connected()
</p>
<p class='vspace'></p><h4>Parameters</h4>
<p>none
</p>
<p class='vspace'></p><h4>Returns</h4>
<p>Returns true if the client is connected, false if not.
</p>
<p class='vspace'></p><h4>Example</h4>
<p>
<div class='sourceblock ' id='sourceblock1'>
<div class='sourceblocktext'><div class="arduino"><span class="co2">#include &lt;Ethernet.h&gt;</span><br />
<span class="co2">#include &lt;SPI.h&gt;</span><br />
<br />
<span class="kw1">byte</span> mac<span class="br0">&#91;</span><span class="br0">&#93;</span> <span class="sy0">=</span> <span class="br0">&#123;</span> <span class="nu12">0xDE</span><span class="sy0">,</span> <span class="nu12">0xAD</span><span class="sy0">,</span> <span class="nu12">0xBE</span><span class="sy0">,</span> <span class="nu12">0xEF</span><span class="sy0">,</span> <span class="nu12">0xFE</span><span class="sy0">,</span> <span class="nu12">0xED</span> <span class="br0">&#125;</span><span class="sy0">;</span><br />
<span class="kw1">byte</span> ip<span class="br0">&#91;</span><span class="br0">&#93;</span> <span class="sy0">=</span> <span class="br0">&#123;</span> <span class="nu0">10</span><span class="sy0">,</span> <span class="nu0">0</span><span class="sy0">,</span> <span class="nu0">0</span><span class="sy0">,</span> <span class="nu0">177</span> <span class="br0">&#125;</span><span class="sy0">;</span><br />
<span class="kw1">byte</span> server<span class="br0">&#91;</span><span class="br0">&#93;</span> <span class="sy0">=</span> <span class="br0">&#123;</span> <span class="nu0">64</span><span class="sy0">,</span> <span class="nu0">233</span><span class="sy0">,</span> <span class="nu0">187</span><span class="sy0">,</span> <span class="nu0">99</span> <span class="br0">&#125;</span><span class="sy0">;</span> <span class="co1">// Google</span><br />
<br />
EthernetClient client<span class="sy0">;</span><br />
<br />
<span class="kw1">void</span> <span class="kw3">setup</span><span class="br0">&#40;</span><span class="br0">&#41;</span><br />
<span class="br0">&#123;</span><br />
&nbsp; Ethernet.<span class="kw1">begin</span><span class="br0">&#40;</span>mac<span class="sy0">,</span> ip<span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; <span class="kw1">Serial</span>.<span class="kw1">begin</span><span class="br0">&#40;</span><span class="nu0">9600</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
<br />
&nbsp; <span class="kw1">delay</span><span class="br0">&#40;</span><span class="nu0">1000</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
<br />
&nbsp; <span class="kw1">Serial</span>.<span class="kw1">println</span><span class="br0">&#40;</span><span class="st0">&quot;connecting...&quot;</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
<br />
&nbsp; <span class="kw1">if</span> <span class="br0">&#40;</span>client.<span class="kw1">connect</span><span class="br0">&#40;</span>server<span class="sy0">,</span> <span class="nu0">80</span><span class="br0">&#41;</span><span class="br0">&#41;</span> <span class="br0">&#123;</span><br />
&nbsp; &nbsp; <span class="kw1">Serial</span>.<span class="kw1">println</span><span class="br0">&#40;</span><span class="st0">&quot;connected&quot;</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; client.<span class="kw1">println</span><span class="br0">&#40;</span><span class="st0">&quot;GET /search?q=arduino HTTP/1.0&quot;</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; client.<span class="kw1">println</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; <span class="br0">&#125;</span> <span class="kw1">else</span> <span class="br0">&#123;</span><br />
&nbsp; &nbsp; <span class="kw1">Serial</span>.<span class="kw1">println</span><span class="br0">&#40;</span><span class="st0">&quot;connection failed&quot;</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; <span class="br0">&#125;</span><br />
<span class="br0">&#125;</span><br />
<br />
<span class="kw1">void</span> <span class="kw3">loop</span><span class="br0">&#40;</span><span class="br0">&#41;</span><br />
<span class="br0">&#123;</span><br />
&nbsp; <span class="kw1">if</span> <span class="br0">&#40;</span>client.<span class="kw1">available</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="br0">&#41;</span> <span class="br0">&#123;</span><br />
&nbsp; &nbsp; <span class="kw1">char</span> c <span class="sy0">=</span> client.<span class="kw1">read</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; <span class="kw1">Serial</span>.<span class="kw1">print</span><span class="br0">&#40;</span>c<span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; <span class="br0">&#125;</span><br />
<br />
&nbsp; <span class="kw1">if</span> <span class="br0">&#40;</span><span class="sy0">!</span>client.<span class="kw1">connected</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="br0">&#41;</span> <span class="br0">&#123;</span><br />
&nbsp; &nbsp; <span class="kw1">Serial</span>.<span class="kw1">println</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; <span class="kw1">Serial</span>.<span class="kw1">println</span><span class="br0">&#40;</span><span class="st0">&quot;disconnecting.&quot;</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; client.<span class="kw1">stop</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; <span class="kw1">for</span><span class="br0">&#40;</span><span class="sy0">;;</span><span class="br0">&#41;</span><br />
&nbsp; &nbsp; &nbsp; <span class="sy0">;</span><br />
&nbsp; <span class="br0">&#125;</span><br />
<span class="br0">&#125;</span></div></div>
<div class='sourceblocklink'><a href='#' type='text/plain'>[Get Code]</a></div>
</div>
</p>
<p class='vspace'></p><p><a class='wikilink' href='index.html'>Reference Home</a>
</p>
<p class='vspace'></p><p><em>Corrections, suggestions, and new documentation should be posted to the <a class='urllink' href='http://arduino.cc/forum/index.php/board,23.0.html' rel='nofollow'>Forum</a>.</em>
</p>
<p class='vspace'></p><p>The text of the Arduino reference is licensed under a
<a class='urllink' href='http://creativecommons.org/licenses/by-sa/3.0/' rel='nofollow'>Creative Commons Attribution-ShareAlike 3.0 License</a>. Code samples in the reference are released into the public domain.
</p>
</div>
</div>
<!--PageFooterFmt-->
<div id="pagefooter">
&copy;Arduino |
<a href='#'>Edit Page</a> | <a href='#'>Page History</a> | <a href='#' target='_blank'>Printable View</a> | <a href='http://arduino.cc/en/Site/AllRecentChanges'>All Recent Site Changes</a>
</div>
<!--/PageFooterFmt-->
</div>
</body>
</html>

View File

@@ -0,0 +1,107 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>Arduino Reference - ClientConstructor </title>
<link rel="shortcut icon" type="image/x-icon" href="http://arduino.cc/en/favicon.png">
<link rel='stylesheet' href='arduinoWideRender.css'
type='text/css' />
<!--HeaderText--><style type='text/css'><!--
ul, ol, pre, dl, p { margin-top:0px; margin-bottom:0px; }
code { white-space: nowrap; }
.vspace { margin-top:1.33em; }
.indent { margin-left:40px; }
.outdent { margin-left:40px; text-indent:-40px; }
a.createlinktext { text-decoration:none; border-bottom:1px dotted gray; }
a.createlink { text-decoration:none; position:relative; top:-0.5em;
font-weight:bold; font-size:smaller; border-bottom:none; }
img { border:0px; }
.editconflict { color:green;
font-style:italic; margin-top:1.33em; margin-bottom:1.33em; }
table.markup { border: 2px dotted #ccf; width:90%; }
td.markup1, td.markup2 { padding-left:10px; padding-right:10px; }
td.markup1 { border-bottom: 1px solid #ccf; }
div.faq { margin-left:2em; }
div.faq p.question { margin: 1em 0 0.75em -2em; font-weight:bold; }
div.faq hr { margin-left: -2em; }
.frame
{ border:1px solid #cccccc; padding:4px; background-color:#f9f9f9; }
.lfloat { float:left; margin-right:0.5em; }
.rfloat { float:right; margin-left:0.5em; }
a.varlink { text-decoration:none; }
--></style> <meta name='robots' content='index,follow' />
<meta name="verify-v1" content="TtxFIEJAB6zdJ509wLxjnapQzKAMNm9u0Wj4ho6wxIY=" />
</head>
<body>
<div id="page">
<!--PageHeaderFmt-->
<div id="pageheader">
<div class="title"><a href='http://arduino.cc/en'>Arduino</a></div>
</div>
<!--/PageHeaderFmt-->
<!--PageLeftFmt-->
<div id="pagenav">
<div id="navbar">
<p><a class='wikilink' href='http://arduino.cc/en/Main/Buy'>Buy</a>
<a class='wikilink' href='http://arduino.cc/en/Main/Software'>Download</a>
<a class='wikilink' href='Guide_index.html'>Getting Started</a>
<a class='wikilink' href='http://arduino.cc/en/Tutorial/HomePage'>Learning</a>
<a class='wikilink' href='index.html'>Reference</a>
<a class='wikilink' href='http://arduino.cc/en/Main/Hardware'>Hardware</a>
<a class='wikilink' href='FAQ.html'>FAQ</a>
</p>
<p class='vspace'></p>
</div>
</div>
<!--/PageLeftFmt-->
<div id="pagetext">
<!--PageText-->
<div id='wikitext'>
<p><strong>Reference</strong> &nbsp; <a class='wikilink' href='index.html'>Language</a> | <a class='wikilink' href='Libraries.html'>Libraries</a> | <a class='wikilink' href='Comparison.html'>Comparison</a> | <a class='wikilink' href='Changes.html'>Changes</a>
</p>
<p class='vspace'></p><p><a class='wikilink' href='Ethernet.html'>Ethernet</a> : <em>Client</em> class
</p>
<p class='vspace'></p><h2>Client</h2>
<h4>Description</h4>
<p>Client is the base class for all Ethernet client based calls. It is not called directly, but invoked whenever you use a function that relies on it.
</p>
<p class='vspace'></p><h4>Functions</h4>
<ul><li><a class='wikilink' href='EthernetClient.html'>EthernetClient()</a>
</li><li><a class='wikilink' href='ClientConnected.html'>connected()</a>
</li><li><a class='wikilink' href='ClientConnect.html'>connect()</a>
</li><li><a class='wikilink' href='ClientWrite.html'>write()</a>
</li><li><a class='wikilink' href='ClientPrint.html'>print()</a>
</li><li><a class='wikilink' href='ClientPrintln.html'>println()</a>
</li><li><a class='wikilink' href='ClientAvailable.html'>available()</a>
</li><li><a class='wikilink' href='ClientRead.html'>read()</a>
</li><li><a class='wikilink' href='ClientFlush.html'>flush()</a>
</li><li><a class='wikilink' href='ClientStop.html'>stop()</a>
</li></ul><p><a class='wikilink' href='index.html'>Reference Home</a>
</p>
<p class='vspace'></p><p><em>Corrections, suggestions, and new documentation should be posted to the <a class='urllink' href='http://arduino.cc/forum/index.php/board,23.0.html' rel='nofollow'>Forum</a>.</em>
</p>
<p class='vspace'></p><p>The text of the Arduino reference is licensed under a
<a class='urllink' href='http://creativecommons.org/licenses/by-sa/3.0/' rel='nofollow'>Creative Commons Attribution-ShareAlike 3.0 License</a>. Code samples in the reference are released into the public domain.
</p>
</div>
</div>
<!--PageFooterFmt-->
<div id="pagefooter">
&copy;Arduino |
<a href='#'>Edit Page</a> | <a href='#'>Page History</a> | <a href='#' target='_blank'>Printable View</a> | <a href='http://arduino.cc/en/Site/AllRecentChanges'>All Recent Site Changes</a>
</div>
<!--/PageFooterFmt-->
</div>
</body>
</html>

View File

@@ -0,0 +1,106 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>Arduino Reference - ClientFlush </title>
<link rel="shortcut icon" type="image/x-icon" href="http://arduino.cc/en/favicon.png">
<link rel='stylesheet' href='arduinoWideRender.css'
type='text/css' />
<!--HeaderText--><style type='text/css'><!--
ul, ol, pre, dl, p { margin-top:0px; margin-bottom:0px; }
code { white-space: nowrap; }
.vspace { margin-top:1.33em; }
.indent { margin-left:40px; }
.outdent { margin-left:40px; text-indent:-40px; }
a.createlinktext { text-decoration:none; border-bottom:1px dotted gray; }
a.createlink { text-decoration:none; position:relative; top:-0.5em;
font-weight:bold; font-size:smaller; border-bottom:none; }
img { border:0px; }
.editconflict { color:green;
font-style:italic; margin-top:1.33em; margin-bottom:1.33em; }
table.markup { border: 2px dotted #ccf; width:90%; }
td.markup1, td.markup2 { padding-left:10px; padding-right:10px; }
td.markup1 { border-bottom: 1px solid #ccf; }
div.faq { margin-left:2em; }
div.faq p.question { margin: 1em 0 0.75em -2em; font-weight:bold; }
div.faq hr { margin-left: -2em; }
.frame
{ border:1px solid #cccccc; padding:4px; background-color:#f9f9f9; }
.lfloat { float:left; margin-right:0.5em; }
.rfloat { float:right; margin-left:0.5em; }
a.varlink { text-decoration:none; }
--></style> <meta name='robots' content='index,follow' />
<meta name="verify-v1" content="TtxFIEJAB6zdJ509wLxjnapQzKAMNm9u0Wj4ho6wxIY=" />
</head>
<body>
<div id="page">
<!--PageHeaderFmt-->
<div id="pageheader">
<div class="title"><a href='http://arduino.cc/en'>Arduino</a></div>
</div>
<!--/PageHeaderFmt-->
<!--PageLeftFmt-->
<div id="pagenav">
<div id="navbar">
<p><a class='wikilink' href='http://arduino.cc/en/Main/Buy'>Buy</a>
<a class='wikilink' href='http://arduino.cc/en/Main/Software'>Download</a>
<a class='wikilink' href='Guide_index.html'>Getting Started</a>
<a class='wikilink' href='http://arduino.cc/en/Tutorial/HomePage'>Learning</a>
<a class='wikilink' href='index.html'>Reference</a>
<a class='wikilink' href='http://arduino.cc/en/Main/Hardware'>Hardware</a>
<a class='wikilink' href='FAQ.html'>FAQ</a>
</p>
<p class='vspace'></p>
</div>
</div>
<!--/PageLeftFmt-->
<div id="pagetext">
<!--PageText-->
<div id='wikitext'>
<p><strong>Reference</strong> &nbsp; <a class='wikilink' href='index.html'>Language</a> | <a class='wikilink' href='Libraries.html'>Libraries</a> | <a class='wikilink' href='Comparison.html'>Comparison</a> | <a class='wikilink' href='Changes.html'>Changes</a>
</p>
<p class='vspace'></p><p><a class='wikilink' href='Ethernet.html'>Ethernet</a> : <em>Client</em> class
</p>
<p class='vspace'></p><h2>flush()</h2>
<p>Discard any bytes that have been written to the client but not yet read.
</p>
<p class='vspace'></p><p>flush() inherits from the <a class='wikilink' href='Stream.html'>Stream</a> utility class.
</p>
<p class='vspace'></p><h4>Syntax</h4>
<p><em>client</em>.flush()
</p>
<p class='vspace'></p><h4>Parameters</h4>
<p>none
</p>
<p class='vspace'></p><h4>Returns</h4>
<p>none
</p>
<p class='vspace'></p><h4>See also</h4>
<ul><li><a class='wikilink' href='StreamFlush.html'>Stream.flush()</a><br /><br /><a class='wikilink' href='index.html'>Reference Home</a>
</li></ul><p class='vspace'></p><p><em>Corrections, suggestions, and new documentation should be posted to the <a class='urllink' href='http://arduino.cc/forum/index.php/board,23.0.html' rel='nofollow'>Forum</a>.</em>
</p>
<p class='vspace'></p><p>The text of the Arduino reference is licensed under a
<a class='urllink' href='http://creativecommons.org/licenses/by-sa/3.0/' rel='nofollow'>Creative Commons Attribution-ShareAlike 3.0 License</a>. Code samples in the reference are released into the public domain.
</p>
</div>
</div>
<!--PageFooterFmt-->
<div id="pagefooter">
&copy;Arduino |
<a href='#'>Edit Page</a> | <a href='#'>Page History</a> | <a href='#' target='_blank'>Printable View</a> | <a href='http://arduino.cc/en/Site/AllRecentChanges'>All Recent Site Changes</a>
</div>
<!--/PageFooterFmt-->
</div>
</body>
</html>

View File

@@ -0,0 +1,106 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>Arduino Reference - ClientPrint </title>
<link rel="shortcut icon" type="image/x-icon" href="http://arduino.cc/en/favicon.png">
<link rel='stylesheet' href='arduinoWideRender.css'
type='text/css' />
<!--HeaderText--><style type='text/css'><!--
ul, ol, pre, dl, p { margin-top:0px; margin-bottom:0px; }
code { white-space: nowrap; }
.vspace { margin-top:1.33em; }
.indent { margin-left:40px; }
.outdent { margin-left:40px; text-indent:-40px; }
a.createlinktext { text-decoration:none; border-bottom:1px dotted gray; }
a.createlink { text-decoration:none; position:relative; top:-0.5em;
font-weight:bold; font-size:smaller; border-bottom:none; }
img { border:0px; }
.editconflict { color:green;
font-style:italic; margin-top:1.33em; margin-bottom:1.33em; }
table.markup { border: 2px dotted #ccf; width:90%; }
td.markup1, td.markup2 { padding-left:10px; padding-right:10px; }
td.markup1 { border-bottom: 1px solid #ccf; }
div.faq { margin-left:2em; }
div.faq p.question { margin: 1em 0 0.75em -2em; font-weight:bold; }
div.faq hr { margin-left: -2em; }
.frame
{ border:1px solid #cccccc; padding:4px; background-color:#f9f9f9; }
.lfloat { float:left; margin-right:0.5em; }
.rfloat { float:right; margin-left:0.5em; }
a.varlink { text-decoration:none; }
--></style> <meta name='robots' content='index,follow' />
<meta name="verify-v1" content="TtxFIEJAB6zdJ509wLxjnapQzKAMNm9u0Wj4ho6wxIY=" />
</head>
<body>
<div id="page">
<!--PageHeaderFmt-->
<div id="pageheader">
<div class="title"><a href='http://arduino.cc/en'>Arduino</a></div>
</div>
<!--/PageHeaderFmt-->
<!--PageLeftFmt-->
<div id="pagenav">
<div id="navbar">
<p><a class='wikilink' href='http://arduino.cc/en/Main/Buy'>Buy</a>
<a class='wikilink' href='http://arduino.cc/en/Main/Software'>Download</a>
<a class='wikilink' href='Guide_index.html'>Getting Started</a>
<a class='wikilink' href='http://arduino.cc/en/Tutorial/HomePage'>Learning</a>
<a class='wikilink' href='index.html'>Reference</a>
<a class='wikilink' href='http://arduino.cc/en/Main/Hardware'>Hardware</a>
<a class='wikilink' href='FAQ.html'>FAQ</a>
</p>
<p class='vspace'></p>
</div>
</div>
<!--/PageLeftFmt-->
<div id="pagetext">
<!--PageText-->
<div id='wikitext'>
<p><strong>Reference</strong> &nbsp; <a class='wikilink' href='index.html'>Language</a> | <a class='wikilink' href='Libraries.html'>Libraries</a> | <a class='wikilink' href='Comparison.html'>Comparison</a> | <a class='wikilink' href='Changes.html'>Changes</a>
</p>
<p class='vspace'></p><p><a class='wikilink' href='Ethernet.html'>Ethernet</a> : <em>Client</em> class
</p>
<p class='vspace'></p><h2>print()</h2>
<h4>Description</h4>
<p>Print data to the server that a client is connected to. Prints numbers as a sequence of digits, each an ASCII character (e.g. the number 123 is sent as the three characters '1', '2', '3').
</p>
<p class='vspace'></p><h4>Syntax</h4>
<p><em>client</em>.print(data) <br /><em>client</em>.print(data, BASE)
</p>
<p class='vspace'></p><h4>Parameters</h4>
<p>data: the data to print (char, byte, int, long, or string)
</p>
<p class='vspace'></p><p>BASE (optional): the base in which to print numbers: DEC for decimal (base 10), OCT for octal (base 8), HEX for hexadecimal (base 16).<br />
</p>
<p class='vspace'></p><h4>Returns</h4>
<p>byte<br />print() will return the number of bytes written, though reading that number is optional
<a class='wikilink' href='index.html'>Reference Home</a>
</p>
<p class='vspace'></p><p><em>Corrections, suggestions, and new documentation should be posted to the <a class='urllink' href='http://arduino.cc/forum/index.php/board,23.0.html' rel='nofollow'>Forum</a>.</em>
</p>
<p class='vspace'></p><p>The text of the Arduino reference is licensed under a
<a class='urllink' href='http://creativecommons.org/licenses/by-sa/3.0/' rel='nofollow'>Creative Commons Attribution-ShareAlike 3.0 License</a>. Code samples in the reference are released into the public domain.
</p>
</div>
</div>
<!--PageFooterFmt-->
<div id="pagefooter">
&copy;Arduino |
<a href='#'>Edit Page</a> | <a href='#'>Page History</a> | <a href='#' target='_blank'>Printable View</a> | <a href='http://arduino.cc/en/Site/AllRecentChanges'>All Recent Site Changes</a>
</div>
<!--/PageFooterFmt-->
</div>
</body>
</html>

View File

@@ -0,0 +1,106 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>Arduino Reference - ClientPrintln </title>
<link rel="shortcut icon" type="image/x-icon" href="http://arduino.cc/en/favicon.png">
<link rel='stylesheet' href='arduinoWideRender.css'
type='text/css' />
<!--HeaderText--><style type='text/css'><!--
ul, ol, pre, dl, p { margin-top:0px; margin-bottom:0px; }
code { white-space: nowrap; }
.vspace { margin-top:1.33em; }
.indent { margin-left:40px; }
.outdent { margin-left:40px; text-indent:-40px; }
a.createlinktext { text-decoration:none; border-bottom:1px dotted gray; }
a.createlink { text-decoration:none; position:relative; top:-0.5em;
font-weight:bold; font-size:smaller; border-bottom:none; }
img { border:0px; }
.editconflict { color:green;
font-style:italic; margin-top:1.33em; margin-bottom:1.33em; }
table.markup { border: 2px dotted #ccf; width:90%; }
td.markup1, td.markup2 { padding-left:10px; padding-right:10px; }
td.markup1 { border-bottom: 1px solid #ccf; }
div.faq { margin-left:2em; }
div.faq p.question { margin: 1em 0 0.75em -2em; font-weight:bold; }
div.faq hr { margin-left: -2em; }
.frame
{ border:1px solid #cccccc; padding:4px; background-color:#f9f9f9; }
.lfloat { float:left; margin-right:0.5em; }
.rfloat { float:right; margin-left:0.5em; }
a.varlink { text-decoration:none; }
--></style> <meta name='robots' content='index,follow' />
<meta name="verify-v1" content="TtxFIEJAB6zdJ509wLxjnapQzKAMNm9u0Wj4ho6wxIY=" />
</head>
<body>
<div id="page">
<!--PageHeaderFmt-->
<div id="pageheader">
<div class="title"><a href='http://arduino.cc/en'>Arduino</a></div>
</div>
<!--/PageHeaderFmt-->
<!--PageLeftFmt-->
<div id="pagenav">
<div id="navbar">
<p><a class='wikilink' href='http://arduino.cc/en/Main/Buy'>Buy</a>
<a class='wikilink' href='http://arduino.cc/en/Main/Software'>Download</a>
<a class='wikilink' href='Guide_index.html'>Getting Started</a>
<a class='wikilink' href='http://arduino.cc/en/Tutorial/HomePage'>Learning</a>
<a class='wikilink' href='index.html'>Reference</a>
<a class='wikilink' href='http://arduino.cc/en/Main/Hardware'>Hardware</a>
<a class='wikilink' href='FAQ.html'>FAQ</a>
</p>
<p class='vspace'></p>
</div>
</div>
<!--/PageLeftFmt-->
<div id="pagetext">
<!--PageText-->
<div id='wikitext'>
<p><strong>Reference</strong> &nbsp; <a class='wikilink' href='index.html'>Language</a> | <a class='wikilink' href='Libraries.html'>Libraries</a> | <a class='wikilink' href='Comparison.html'>Comparison</a> | <a class='wikilink' href='Changes.html'>Changes</a>
</p>
<p class='vspace'></p><p><a class='wikilink' href='Ethernet.html'>Ethernet</a> : <em>Client</em> class
</p>
<p class='vspace'></p><h2>println()</h2>
<h4>Description</h4>
<p>Print data, followed by a carriage return and newline, to the server a client is connected to. Prints numbers as a sequence of digits, each an ASCII character (e.g. the number 123 is sent as the three characters '1', '2', '3').
</p>
<p class='vspace'></p><h4>Syntax</h4>
<p><em>client</em>.println() <br /><em>client</em>.println(data) <br /><em>client</em>.print(data, BASE)
</p>
<p class='vspace'></p><h4>Parameters</h4>
<p>data (optional): the data to print (char, byte, int, long, or string)
</p>
<p class='vspace'></p><p>BASE (optional): the base in which to print numbers: DEC for decimal (base 10), OCT for octal (base 8), HEX for hexadecimal (base 16).
</p>
<p class='vspace'></p><h4>Returns</h4>
<p>byte<br />print()ln will return the number of bytes written, though reading that number is optional
<a class='wikilink' href='index.html'>Reference Home</a>
</p>
<p class='vspace'></p><p><em>Corrections, suggestions, and new documentation should be posted to the <a class='urllink' href='http://arduino.cc/forum/index.php/board,23.0.html' rel='nofollow'>Forum</a>.</em>
</p>
<p class='vspace'></p><p>The text of the Arduino reference is licensed under a
<a class='urllink' href='http://creativecommons.org/licenses/by-sa/3.0/' rel='nofollow'>Creative Commons Attribution-ShareAlike 3.0 License</a>. Code samples in the reference are released into the public domain.
</p>
</div>
</div>
<!--PageFooterFmt-->
<div id="pagefooter">
&copy;Arduino |
<a href='#'>Edit Page</a> | <a href='#'>Page History</a> | <a href='#' target='_blank'>Printable View</a> | <a href='http://arduino.cc/en/Site/AllRecentChanges'>All Recent Site Changes</a>
</div>
<!--/PageFooterFmt-->
</div>
</body>
</html>

View File

@@ -0,0 +1,106 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>Arduino Reference - ClientRead </title>
<link rel="shortcut icon" type="image/x-icon" href="http://arduino.cc/en/favicon.png">
<link rel='stylesheet' href='arduinoWideRender.css'
type='text/css' />
<!--HeaderText--><style type='text/css'><!--
ul, ol, pre, dl, p { margin-top:0px; margin-bottom:0px; }
code { white-space: nowrap; }
.vspace { margin-top:1.33em; }
.indent { margin-left:40px; }
.outdent { margin-left:40px; text-indent:-40px; }
a.createlinktext { text-decoration:none; border-bottom:1px dotted gray; }
a.createlink { text-decoration:none; position:relative; top:-0.5em;
font-weight:bold; font-size:smaller; border-bottom:none; }
img { border:0px; }
.editconflict { color:green;
font-style:italic; margin-top:1.33em; margin-bottom:1.33em; }
table.markup { border: 2px dotted #ccf; width:90%; }
td.markup1, td.markup2 { padding-left:10px; padding-right:10px; }
td.markup1 { border-bottom: 1px solid #ccf; }
div.faq { margin-left:2em; }
div.faq p.question { margin: 1em 0 0.75em -2em; font-weight:bold; }
div.faq hr { margin-left: -2em; }
.frame
{ border:1px solid #cccccc; padding:4px; background-color:#f9f9f9; }
.lfloat { float:left; margin-right:0.5em; }
.rfloat { float:right; margin-left:0.5em; }
a.varlink { text-decoration:none; }
--></style> <meta name='robots' content='index,follow' />
<meta name="verify-v1" content="TtxFIEJAB6zdJ509wLxjnapQzKAMNm9u0Wj4ho6wxIY=" />
</head>
<body>
<div id="page">
<!--PageHeaderFmt-->
<div id="pageheader">
<div class="title"><a href='http://arduino.cc/en'>Arduino</a></div>
</div>
<!--/PageHeaderFmt-->
<!--PageLeftFmt-->
<div id="pagenav">
<div id="navbar">
<p><a class='wikilink' href='http://arduino.cc/en/Main/Buy'>Buy</a>
<a class='wikilink' href='http://arduino.cc/en/Main/Software'>Download</a>
<a class='wikilink' href='Guide_index.html'>Getting Started</a>
<a class='wikilink' href='http://arduino.cc/en/Tutorial/HomePage'>Learning</a>
<a class='wikilink' href='index.html'>Reference</a>
<a class='wikilink' href='http://arduino.cc/en/Main/Hardware'>Hardware</a>
<a class='wikilink' href='FAQ.html'>FAQ</a>
</p>
<p class='vspace'></p>
</div>
</div>
<!--/PageLeftFmt-->
<div id="pagetext">
<!--PageText-->
<div id='wikitext'>
<p><strong>Reference</strong> &nbsp; <a class='wikilink' href='index.html'>Language</a> | <a class='wikilink' href='Libraries.html'>Libraries</a> | <a class='wikilink' href='Comparison.html'>Comparison</a> | <a class='wikilink' href='Changes.html'>Changes</a>
</p>
<p class='vspace'></p><p><a class='wikilink' href='Ethernet.html'>Ethernet</a> : <em>Client</em> class
</p>
<p class='vspace'></p><h2>read()</h2>
<p>Read the next byte received from the server the client is connected to (after the last call to read()).
</p>
<p class='vspace'></p><p>read() inherits from the <a class='wikilink' href='Stream.html'>Stream</a> utility class.
</p>
<p class='vspace'></p><h4>Syntax</h4>
<p><em>client</em>.read()
</p>
<p class='vspace'></p><h4>Parameters</h4>
<p>none
</p>
<p class='vspace'></p><h4>Returns</h4>
<p>The next byte (or character), or -1 if none is available.
</p>
<p class='vspace'></p><h4>See Also</h4>
<ul><li><a class='wikilink' href='StreamRead.html'>Stream.read()</a><br /><br /><a class='wikilink' href='index.html'>Reference Home</a>
</li></ul><p class='vspace'></p><p><em>Corrections, suggestions, and new documentation should be posted to the <a class='urllink' href='http://arduino.cc/forum/index.php/board,23.0.html' rel='nofollow'>Forum</a>.</em>
</p>
<p class='vspace'></p><p>The text of the Arduino reference is licensed under a
<a class='urllink' href='http://creativecommons.org/licenses/by-sa/3.0/' rel='nofollow'>Creative Commons Attribution-ShareAlike 3.0 License</a>. Code samples in the reference are released into the public domain.
</p>
</div>
</div>
<!--PageFooterFmt-->
<div id="pagefooter">
&copy;Arduino |
<a href='#'>Edit Page</a> | <a href='#'>Page History</a> | <a href='#' target='_blank'>Printable View</a> | <a href='http://arduino.cc/en/Site/AllRecentChanges'>All Recent Site Changes</a>
</div>
<!--/PageFooterFmt-->
</div>
</body>
</html>

View File

@@ -0,0 +1,103 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>Arduino Reference - ClientStop </title>
<link rel="shortcut icon" type="image/x-icon" href="http://arduino.cc/en/favicon.png">
<link rel='stylesheet' href='arduinoWideRender.css'
type='text/css' />
<!--HeaderText--><style type='text/css'><!--
ul, ol, pre, dl, p { margin-top:0px; margin-bottom:0px; }
code { white-space: nowrap; }
.vspace { margin-top:1.33em; }
.indent { margin-left:40px; }
.outdent { margin-left:40px; text-indent:-40px; }
a.createlinktext { text-decoration:none; border-bottom:1px dotted gray; }
a.createlink { text-decoration:none; position:relative; top:-0.5em;
font-weight:bold; font-size:smaller; border-bottom:none; }
img { border:0px; }
.editconflict { color:green;
font-style:italic; margin-top:1.33em; margin-bottom:1.33em; }
table.markup { border: 2px dotted #ccf; width:90%; }
td.markup1, td.markup2 { padding-left:10px; padding-right:10px; }
td.markup1 { border-bottom: 1px solid #ccf; }
div.faq { margin-left:2em; }
div.faq p.question { margin: 1em 0 0.75em -2em; font-weight:bold; }
div.faq hr { margin-left: -2em; }
.frame
{ border:1px solid #cccccc; padding:4px; background-color:#f9f9f9; }
.lfloat { float:left; margin-right:0.5em; }
.rfloat { float:right; margin-left:0.5em; }
a.varlink { text-decoration:none; }
--></style> <meta name='robots' content='index,follow' />
<meta name="verify-v1" content="TtxFIEJAB6zdJ509wLxjnapQzKAMNm9u0Wj4ho6wxIY=" />
</head>
<body>
<div id="page">
<!--PageHeaderFmt-->
<div id="pageheader">
<div class="title"><a href='http://arduino.cc/en'>Arduino</a></div>
</div>
<!--/PageHeaderFmt-->
<!--PageLeftFmt-->
<div id="pagenav">
<div id="navbar">
<p><a class='wikilink' href='http://arduino.cc/en/Main/Buy'>Buy</a>
<a class='wikilink' href='http://arduino.cc/en/Main/Software'>Download</a>
<a class='wikilink' href='Guide_index.html'>Getting Started</a>
<a class='wikilink' href='http://arduino.cc/en/Tutorial/HomePage'>Learning</a>
<a class='wikilink' href='index.html'>Reference</a>
<a class='wikilink' href='http://arduino.cc/en/Main/Hardware'>Hardware</a>
<a class='wikilink' href='FAQ.html'>FAQ</a>
</p>
<p class='vspace'></p>
</div>
</div>
<!--/PageLeftFmt-->
<div id="pagetext">
<!--PageText-->
<div id='wikitext'>
<p><strong>Reference</strong> &nbsp; <a class='wikilink' href='index.html'>Language</a> | <a class='wikilink' href='Libraries.html'>Libraries</a> | <a class='wikilink' href='Comparison.html'>Comparison</a> | <a class='wikilink' href='Changes.html'>Changes</a>
</p>
<p class='vspace'></p><p><a class='wikilink' href='Ethernet.html'>Ethernet</a> : <em>Client</em> class
</p>
<p class='vspace'></p><h2>stop()</h2>
<h4>Description</h4>
<p>Disconnect from the server.
</p>
<p class='vspace'></p><h4>Syntax</h4>
<p><em>client</em>.stop()
</p>
<p class='vspace'></p><h4>Parameters</h4>
<p>none
</p>
<p class='vspace'></p><h4>Returns</h4>
<p>none<br /><br /><a class='wikilink' href='index.html'>Reference Home</a>
</p>
<p class='vspace'></p><p><em>Corrections, suggestions, and new documentation should be posted to the <a class='urllink' href='http://arduino.cc/forum/index.php/board,23.0.html' rel='nofollow'>Forum</a>.</em>
</p>
<p class='vspace'></p><p>The text of the Arduino reference is licensed under a
<a class='urllink' href='http://creativecommons.org/licenses/by-sa/3.0/' rel='nofollow'>Creative Commons Attribution-ShareAlike 3.0 License</a>. Code samples in the reference are released into the public domain.
</p>
</div>
</div>
<!--PageFooterFmt-->
<div id="pagefooter">
&copy;Arduino |
<a href='#'>Edit Page</a> | <a href='#'>Page History</a> | <a href='#' target='_blank'>Printable View</a> | <a href='http://arduino.cc/en/Site/AllRecentChanges'>All Recent Site Changes</a>
</div>
<!--/PageFooterFmt-->
</div>
</body>
</html>

View File

@@ -0,0 +1,103 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>Arduino Reference - ClientWrite </title>
<link rel="shortcut icon" type="image/x-icon" href="http://arduino.cc/en/favicon.png">
<link rel='stylesheet' href='arduinoWideRender.css'
type='text/css' />
<!--HeaderText--><style type='text/css'><!--
ul, ol, pre, dl, p { margin-top:0px; margin-bottom:0px; }
code { white-space: nowrap; }
.vspace { margin-top:1.33em; }
.indent { margin-left:40px; }
.outdent { margin-left:40px; text-indent:-40px; }
a.createlinktext { text-decoration:none; border-bottom:1px dotted gray; }
a.createlink { text-decoration:none; position:relative; top:-0.5em;
font-weight:bold; font-size:smaller; border-bottom:none; }
img { border:0px; }
.editconflict { color:green;
font-style:italic; margin-top:1.33em; margin-bottom:1.33em; }
table.markup { border: 2px dotted #ccf; width:90%; }
td.markup1, td.markup2 { padding-left:10px; padding-right:10px; }
td.markup1 { border-bottom: 1px solid #ccf; }
div.faq { margin-left:2em; }
div.faq p.question { margin: 1em 0 0.75em -2em; font-weight:bold; }
div.faq hr { margin-left: -2em; }
.frame
{ border:1px solid #cccccc; padding:4px; background-color:#f9f9f9; }
.lfloat { float:left; margin-right:0.5em; }
.rfloat { float:right; margin-left:0.5em; }
a.varlink { text-decoration:none; }
--></style> <meta name='robots' content='index,follow' />
<meta name="verify-v1" content="TtxFIEJAB6zdJ509wLxjnapQzKAMNm9u0Wj4ho6wxIY=" />
</head>
<body>
<div id="page">
<!--PageHeaderFmt-->
<div id="pageheader">
<div class="title"><a href='http://arduino.cc/en'>Arduino</a></div>
</div>
<!--/PageHeaderFmt-->
<!--PageLeftFmt-->
<div id="pagenav">
<div id="navbar">
<p><a class='wikilink' href='http://arduino.cc/en/Main/Buy'>Buy</a>
<a class='wikilink' href='http://arduino.cc/en/Main/Software'>Download</a>
<a class='wikilink' href='Guide_index.html'>Getting Started</a>
<a class='wikilink' href='http://arduino.cc/en/Tutorial/HomePage'>Learning</a>
<a class='wikilink' href='index.html'>Reference</a>
<a class='wikilink' href='http://arduino.cc/en/Main/Hardware'>Hardware</a>
<a class='wikilink' href='FAQ.html'>FAQ</a>
</p>
<p class='vspace'></p>
</div>
</div>
<!--/PageLeftFmt-->
<div id="pagetext">
<!--PageText-->
<div id='wikitext'>
<p><strong>Reference</strong> &nbsp; <a class='wikilink' href='index.html'>Language</a> | <a class='wikilink' href='Libraries.html'>Libraries</a> | <a class='wikilink' href='Comparison.html'>Comparison</a> | <a class='wikilink' href='Changes.html'>Changes</a>
</p>
<p class='vspace'></p><p><a class='wikilink' href='Ethernet.html'>Ethernet</a> : <em>Client</em> class
</p>
<p class='vspace'></p><h2>write()</h2>
<h4>Description</h4>
<p>Write data to the server the client is connected to.
</p>
<p class='vspace'></p><h4>Syntax</h4>
<p><em>client</em>.write(data)
</p>
<p class='vspace'></p><h4>Parameters</h4>
<p>data: the byte or char to write
</p>
<p class='vspace'></p><h4>Returns</h4>
<p>byte: the number of characters written. it is not necessary to read this value.<br /><br /><a class='wikilink' href='index.html'>Reference Home</a>
</p>
<p class='vspace'></p><p><em>Corrections, suggestions, and new documentation should be posted to the <a class='urllink' href='http://arduino.cc/forum/index.php/board,23.0.html' rel='nofollow'>Forum</a>.</em>
</p>
<p class='vspace'></p><p>The text of the Arduino reference is licensed under a
<a class='urllink' href='http://creativecommons.org/licenses/by-sa/3.0/' rel='nofollow'>Creative Commons Attribution-ShareAlike 3.0 License</a>. Code samples in the reference are released into the public domain.
</p>
</div>
</div>
<!--PageFooterFmt-->
<div id="pagefooter">
&copy;Arduino |
<a href='#'>Edit Page</a> | <a href='#'>Page History</a> | <a href='#' target='_blank'>Printable View</a> | <a href='http://arduino.cc/en/Site/AllRecentChanges'>All Recent Site Changes</a>
</div>
<!--/PageFooterFmt-->
</div>
</body>
</html>

View File

@@ -0,0 +1,111 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>Arduino Reference - Comments </title>
<link rel="shortcut icon" type="image/x-icon" href="http://arduino.cc/en/favicon.png">
<link rel='stylesheet' href='arduinoWideRender.css'
type='text/css' />
<!--HeaderText--><style type='text/css'><!--
ul, ol, pre, dl, p { margin-top:0px; margin-bottom:0px; }
code { white-space: nowrap; }
.vspace { margin-top:1.33em; }
.indent { margin-left:40px; }
.outdent { margin-left:40px; text-indent:-40px; }
a.createlinktext { text-decoration:none; border-bottom:1px dotted gray; }
a.createlink { text-decoration:none; position:relative; top:-0.5em;
font-weight:bold; font-size:smaller; border-bottom:none; }
img { border:0px; }
.editconflict { color:green;
font-style:italic; margin-top:1.33em; margin-bottom:1.33em; }
table.markup { border: 2px dotted #ccf; width:90%; }
td.markup1, td.markup2 { padding-left:10px; padding-right:10px; }
td.markup1 { border-bottom: 1px solid #ccf; }
div.faq { margin-left:2em; }
div.faq p.question { margin: 1em 0 0.75em -2em; font-weight:bold; }
div.faq hr { margin-left: -2em; }
.frame
{ border:1px solid #cccccc; padding:4px; background-color:#f9f9f9; }
.lfloat { float:left; margin-right:0.5em; }
.rfloat { float:right; margin-left:0.5em; }
a.varlink { text-decoration:none; }
--></style> <meta name='robots' content='index,follow' />
<meta name="verify-v1" content="TtxFIEJAB6zdJ509wLxjnapQzKAMNm9u0Wj4ho6wxIY=" />
</head>
<body>
<div id="page">
<!--PageHeaderFmt-->
<div id="pageheader">
<div class="title"><a href='http://arduino.cc/en'>Arduino</a></div>
</div>
<!--/PageHeaderFmt-->
<!--PageLeftFmt-->
<div id="pagenav">
<div id="navbar">
<p><a class='wikilink' href='http://arduino.cc/en/Main/Buy'>Buy</a>
<a class='wikilink' href='http://arduino.cc/en/Main/Software'>Download</a>
<a class='wikilink' href='Guide_index.html'>Getting Started</a>
<a class='wikilink' href='http://arduino.cc/en/Tutorial/HomePage'>Learning</a>
<a class='wikilink' href='index.html'>Reference</a>
<a class='wikilink' href='http://arduino.cc/en/Main/Hardware'>Hardware</a>
<a class='wikilink' href='FAQ.html'>FAQ</a>
</p>
<p class='vspace'></p>
</div>
</div>
<!--/PageLeftFmt-->
<div id="pagetext">
<!--PageText-->
<div id='wikitext'>
<p><strong>Reference</strong> &nbsp; <a class='wikilink' href='index.html'>Language</a> | <a class='wikilink' href='Libraries.html'>Libraries</a> | <a class='wikilink' href='Comparison.html'>Comparison</a> | <a class='wikilink' href='Changes.html'>Changes</a>
</p>
<p class='vspace'></p><h2>Comments</h2>
<p>Comments are lines in the program that are used to inform yourself or others about the way the program works. They are ignored by the compiler, and not exported to the processor, so they don't take up any space on the Atmega chip.
</p>
<p class='vspace'></p><p>Comments only purpose are to help you understand (or remember) how your program works or to inform others how your program works.
There are two different ways of marking a line as a comment:
</p>
<p class='vspace'></p><h4>Example</h4>
<pre> x = 5; // This is a single line comment. Anything after the slashes is a comment
// to the end of the line
/* this is multiline comment - use it to comment out whole blocks of code
if (gwb == 0){ // single line comment is OK inside a multiline comment
x = 3; /* but not another multiline comment - this is invalid */
}
// don't forget the "closing" comment - they have to be balanced!
*/
</pre>
<p class='vspace'></p><p><strong>Tip</strong><br />When experimenting with code, "commenting out" parts of your program is a convenient way to remove lines that may be buggy. This leaves the lines in the code, but turns them into comments, so the compiler just ignores them. This can be especially useful when trying to locate a problem, or when a program refuses to compile and the compiler error is cryptic or unhelpful.
</p>
<p class='vspace'></p><p><a class='wikilink' href='index.html'>Reference Home</a>
</p>
<p class='vspace'></p><p><em>Corrections, suggestions, and new documentation should be posted to the <a class='urllink' href='http://arduino.cc/forum/index.php/board,23.0.html' rel='nofollow'>Forum</a>.</em>
</p>
<p class='vspace'></p><p>The text of the Arduino reference is licensed under a
<a class='urllink' href='http://creativecommons.org/licenses/by-sa/3.0/' rel='nofollow'>Creative Commons Attribution-ShareAlike 3.0 License</a>. Code samples in the reference are released into the public domain.
</p>
</div>
</div>
<!--PageFooterFmt-->
<div id="pagefooter">
&copy;Arduino |
<a href='#'>Edit Page</a> | <a href='#'>Page History</a> | <a href='#' target='_blank'>Printable View</a> | <a href='http://arduino.cc/en/Site/AllRecentChanges'>All Recent Site Changes</a>
</div>
<!--/PageFooterFmt-->
</div>
</body>
</html>

View File

@@ -0,0 +1,117 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>Arduino Reference - Comparison </title>
<link rel="shortcut icon" type="image/x-icon" href="http://arduino.cc/en/favicon.png">
<link rel='stylesheet' href='arduinoWideRender.css'
type='text/css' />
<!--HeaderText--><style type='text/css'><!--
ul, ol, pre, dl, p { margin-top:0px; margin-bottom:0px; }
code { white-space: nowrap; }
.vspace { margin-top:1.33em; }
.indent { margin-left:40px; }
.outdent { margin-left:40px; text-indent:-40px; }
a.createlinktext { text-decoration:none; border-bottom:1px dotted gray; }
a.createlink { text-decoration:none; position:relative; top:-0.5em;
font-weight:bold; font-size:smaller; border-bottom:none; }
img { border:0px; }
.editconflict { color:green;
font-style:italic; margin-top:1.33em; margin-bottom:1.33em; }
table.markup { border: 2px dotted #ccf; width:90%; }
td.markup1, td.markup2 { padding-left:10px; padding-right:10px; }
td.markup1 { border-bottom: 1px solid #ccf; }
div.faq { margin-left:2em; }
div.faq p.question { margin: 1em 0 0.75em -2em; font-weight:bold; }
div.faq hr { margin-left: -2em; }
.frame
{ border:1px solid #cccccc; padding:4px; background-color:#f9f9f9; }
.lfloat { float:left; margin-right:0.5em; }
.rfloat { float:right; margin-left:0.5em; }
a.varlink { text-decoration:none; }
--></style> <meta name='robots' content='index,follow' />
<meta name="verify-v1" content="TtxFIEJAB6zdJ509wLxjnapQzKAMNm9u0Wj4ho6wxIY=" />
</head>
<body>
<div id="page">
<!--PageHeaderFmt-->
<div id="pageheader">
<div class="title"><a href='http://arduino.cc/en'>Arduino</a></div>
</div>
<!--/PageHeaderFmt-->
<!--PageLeftFmt-->
<div id="pagenav">
<div id="navbar">
<p><a class='wikilink' href='http://arduino.cc/en/Main/Buy'>Buy</a>
<a class='wikilink' href='http://arduino.cc/en/Main/Software'>Download</a>
<a class='wikilink' href='Guide_index.html'>Getting Started</a>
<a class='wikilink' href='http://arduino.cc/en/Tutorial/HomePage'>Learning</a>
<a class='wikilink' href='index.html'>Reference</a>
<a class='wikilink' href='http://arduino.cc/en/Main/Hardware'>Hardware</a>
<a class='wikilink' href='FAQ.html'>FAQ</a>
</p>
<p class='vspace'></p>
</div>
</div>
<!--/PageLeftFmt-->
<div id="pagetext">
<!--PageText-->
<div id='wikitext'>
<p><strong>Reference</strong> &nbsp; <a class='wikilink' href='index.html'>Language</a> | <a class='wikilink' href='Libraries.html'>Libraries</a> | <a class='selflink' href='Comparison.html'>Comparison</a> | <a class='wikilink' href='Changes.html'>Changes</a>
</p>
<p class='vspace'></p><h2>Arduino/Processing Language Comparison</h2>
<p>The Arduino language (based on Wiring) is implemented in C/C++, and therefore has some differences from the Processing language, which is based on Java.
</p>
<p class='vspace'></p><h3>Arrays</h3>
<table width='75%' cellspacing='0' cellpadding='5'><tr><td width='50%' bgcolor='#999999' valign='top'> <em>Arduino</em>
</td><td width='50%' bgcolor='#CCCCCC' valign='top'> <em>Processing</em>
</td></tr><tr><td valign='top'> int bar[8]; <br clear='all' /> bar[0] = 1;
</td><td valign='top'> int[] bar = new int[8]; <br clear='all' /> bar[0] = 1;
</td></tr><tr><td bgcolor='#999999' valign='top'> int foo[] = { 0, 1, 2 };
</td><td bgcolor='#CCCCCC' valign='top'> int foo[] = { 0, 1, 2 }; <br clear='all' /> <em>or</em> <br clear='all' /> int[] foo = { 0, 1, 2 };
</td></tr></table>
<p class='vspace'></p><h3>Loops</h3>
<table width='75%' cellspacing='0' cellpadding='5'><tr><td width='50%' bgcolor='#999999' valign='top'> <em>Arduino</em>
</td><td width='50%' bgcolor='#CCCCCC' valign='top'> <em>Processing</em>
</td></tr><tr><td valign='top'> int i; <br clear='all' /> for (i = 0; i &lt; 5; i++) { ... }
</td><td valign='top'> for (int i = 0; i &lt; 5; i++) { ... }
</td></tr></table>
<p class='vspace'></p><h3>Printing</h3>
<table width='75%' cellspacing='0' cellpadding='5'><tr><td width='50%' bgcolor='#999999' valign='top'> <em>Arduino</em>
</td><td width='50%' bgcolor='#CCCCCC' valign='top'> <em>Processing</em>
</td></tr><tr><td valign='top'> Serial.println("hello world");
</td><td valign='top'> println("hello world");
</td></tr><tr><td bgcolor='#999999' valign='top'> int i = 5; <br clear='all' /> Serial.println(i);
</td><td bgcolor='#CCCCCC' valign='top'> int i = 5; <br clear='all' /> println(i);
</td></tr><tr><td valign='top'> int i = 5; <br clear='all' /> Serial.print("i = "); <br clear='all' /> Serial.print(i); <br clear='all' /> Serial.println();
</td><td valign='top'> int i = 5; <br clear='all' /> println("i = " + i);
</td></tr></table>
<p class='vspace'></p><p><a class='wikilink' href='index.html'>Reference Home</a>
</p>
<p class='vspace'></p><p><em>Corrections, suggestions, and new documentation should be posted to the <a class='urllink' href='http://arduino.cc/forum/index.php/board,23.0.html' rel='nofollow'>Forum</a>.</em>
</p>
<p class='vspace'></p><p>The text of the Arduino reference is licensed under a
<a class='urllink' href='http://creativecommons.org/licenses/by-sa/3.0/' rel='nofollow'>Creative Commons Attribution-ShareAlike 3.0 License</a>. Code samples in the reference are released into the public domain.
</p>
</div>
</div>
<!--PageFooterFmt-->
<div id="pagefooter">
&copy;Arduino |
<a href='#'>Edit Page</a> | <a href='#'>Page History</a> | <a href='#' target='_blank'>Printable View</a> | <a href='http://arduino.cc/en/Site/AllRecentChanges'>All Recent Site Changes</a>
</div>
<!--/PageFooterFmt-->
</div>
</body>
</html>

View File

@@ -0,0 +1,113 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>Arduino Reference - Const </title>
<link rel="shortcut icon" type="image/x-icon" href="http://arduino.cc/en/favicon.png">
<link rel='stylesheet' href='arduinoWideRender.css'
type='text/css' />
<!--HeaderText--><style type='text/css'><!--
ul, ol, pre, dl, p { margin-top:0px; margin-bottom:0px; }
code { white-space: nowrap; }
.vspace { margin-top:1.33em; }
.indent { margin-left:40px; }
.outdent { margin-left:40px; text-indent:-40px; }
a.createlinktext { text-decoration:none; border-bottom:1px dotted gray; }
a.createlink { text-decoration:none; position:relative; top:-0.5em;
font-weight:bold; font-size:smaller; border-bottom:none; }
img { border:0px; }
.editconflict { color:green;
font-style:italic; margin-top:1.33em; margin-bottom:1.33em; }
table.markup { border: 2px dotted #ccf; width:90%; }
td.markup1, td.markup2 { padding-left:10px; padding-right:10px; }
td.markup1 { border-bottom: 1px solid #ccf; }
div.faq { margin-left:2em; }
div.faq p.question { margin: 1em 0 0.75em -2em; font-weight:bold; }
div.faq hr { margin-left: -2em; }
.frame
{ border:1px solid #cccccc; padding:4px; background-color:#f9f9f9; }
.lfloat { float:left; margin-right:0.5em; }
.rfloat { float:right; margin-left:0.5em; }
a.varlink { text-decoration:none; }
--></style> <meta name='robots' content='index,follow' />
<meta name="verify-v1" content="TtxFIEJAB6zdJ509wLxjnapQzKAMNm9u0Wj4ho6wxIY=" />
</head>
<body>
<div id="page">
<!--PageHeaderFmt-->
<div id="pageheader">
<div class="title"><a href='http://arduino.cc/en'>Arduino</a></div>
</div>
<!--/PageHeaderFmt-->
<!--PageLeftFmt-->
<div id="pagenav">
<div id="navbar">
<p><a class='wikilink' href='http://arduino.cc/en/Main/Buy'>Buy</a>
<a class='wikilink' href='http://arduino.cc/en/Main/Software'>Download</a>
<a class='wikilink' href='Guide_index.html'>Getting Started</a>
<a class='wikilink' href='http://arduino.cc/en/Tutorial/HomePage'>Learning</a>
<a class='wikilink' href='index.html'>Reference</a>
<a class='wikilink' href='http://arduino.cc/en/Main/Hardware'>Hardware</a>
<a class='wikilink' href='FAQ.html'>FAQ</a>
</p>
<p class='vspace'></p>
</div>
</div>
<!--/PageLeftFmt-->
<div id="pagetext">
<!--PageText-->
<div id='wikitext'>
<p><strong>Reference</strong> &nbsp; <a class='wikilink' href='index.html'>Language</a> | <a class='wikilink' href='Libraries.html'>Libraries</a> | <a class='wikilink' href='Comparison.html'>Comparison</a> | <a class='wikilink' href='Changes.html'>Changes</a>
</p>
<p class='vspace'></p><h2>const keyword</h2>
<p>The <strong>const</strong> keyword stands for constant. It is a variable <em>qualifier</em> that modifies the behavior of the variable, making a variable "<em>read-only</em>". This means that the variable can be used just as any other variable of its type, but its value cannot be changed. You will get a compiler error if you try to assign a value to a <strong>const</strong> variable.
</p>
<p class='vspace'></p><p>Constants defined with the <em>const</em> keyword obey the rules of <em><a class='wikilink' href='Scope.html'>variable scoping</a></em> that govern other variables. This, and the pitfalls of using<em>#define</em>, makes the <em>const</em> keyword a superior method for defining constants and is preferred over using <em><a class='wikilink' href='Define.html'>#define</a></em>.
</p>
<p class='vspace'></p><h4>Example</h4>
<pre>
const float pi = 3.14;
float x;
// ....
x = pi * 2; // it's fine to use const's in math
pi = 7; // illegal - you can't write to (modify) a constant
</pre><h4><strong>#define</strong> or <strong>const</strong></h4>
<p>You can use either <strong>const</strong> or <strong>#define</strong> for creating numeric or string constants. For <a class='wikilink' href='Array.html'>arrays</a>, you will need to use <strong>const</strong>. In general <em>const</em> is preferred over <em>#define</em> for defining constants.
</p>
<p class='vspace'></p><p>See also:
</p><ul><li><a class='wikilink' href='Define.html'>#define</a>
</li><li><a class='wikilink' href='Volatile.html'>volatile</a>
</li></ul><p><a class='wikilink' href='index.html'>Reference Home</a>
</p>
<p class='vspace'></p><p><em>Corrections, suggestions, and new documentation should be posted to the <a class='urllink' href='http://arduino.cc/forum/index.php/board,23.0.html' rel='nofollow'>Forum</a>.</em>
</p>
<p class='vspace'></p><p>The text of the Arduino reference is licensed under a
<a class='urllink' href='http://creativecommons.org/licenses/by-sa/3.0/' rel='nofollow'>Creative Commons Attribution-ShareAlike 3.0 License</a>. Code samples in the reference are released into the public domain.
</p>
</div>
</div>
<!--PageFooterFmt-->
<div id="pagefooter">
&copy;Arduino |
<a href='#'>Edit Page</a> | <a href='#'>Page History</a> | <a href='#' target='_blank'>Printable View</a> | <a href='http://arduino.cc/en/Site/AllRecentChanges'>All Recent Site Changes</a>
</div>
<!--/PageFooterFmt-->
</div>
</body>
</html>

View File

@@ -0,0 +1,135 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>Arduino Reference - Constants </title>
<link rel="shortcut icon" type="image/x-icon" href="http://arduino.cc/en/favicon.png">
<link rel='stylesheet' href='arduinoWideRender.css'
type='text/css' />
<!--HeaderText--><style type='text/css'><!--
ul, ol, pre, dl, p { margin-top:0px; margin-bottom:0px; }
code { white-space: nowrap; }
.vspace { margin-top:1.33em; }
.indent { margin-left:40px; }
.outdent { margin-left:40px; text-indent:-40px; }
a.createlinktext { text-decoration:none; border-bottom:1px dotted gray; }
a.createlink { text-decoration:none; position:relative; top:-0.5em;
font-weight:bold; font-size:smaller; border-bottom:none; }
img { border:0px; }
.editconflict { color:green;
font-style:italic; margin-top:1.33em; margin-bottom:1.33em; }
table.markup { border: 2px dotted #ccf; width:90%; }
td.markup1, td.markup2 { padding-left:10px; padding-right:10px; }
td.markup1 { border-bottom: 1px solid #ccf; }
div.faq { margin-left:2em; }
div.faq p.question { margin: 1em 0 0.75em -2em; font-weight:bold; }
div.faq hr { margin-left: -2em; }
.frame
{ border:1px solid #cccccc; padding:4px; background-color:#f9f9f9; }
.lfloat { float:left; margin-right:0.5em; }
.rfloat { float:right; margin-left:0.5em; }
a.varlink { text-decoration:none; }
--></style> <meta name='robots' content='index,follow' />
<meta name="verify-v1" content="TtxFIEJAB6zdJ509wLxjnapQzKAMNm9u0Wj4ho6wxIY=" />
</head>
<body>
<div id="page">
<!--PageHeaderFmt-->
<div id="pageheader">
<div class="title"><a href='http://arduino.cc/en'>Arduino</a></div>
</div>
<!--/PageHeaderFmt-->
<!--PageLeftFmt-->
<div id="pagenav">
<div id="navbar">
<p><a class='wikilink' href='http://arduino.cc/en/Main/Buy'>Buy</a>
<a class='wikilink' href='http://arduino.cc/en/Main/Software'>Download</a>
<a class='wikilink' href='Guide_index.html'>Getting Started</a>
<a class='wikilink' href='http://arduino.cc/en/Tutorial/HomePage'>Learning</a>
<a class='wikilink' href='index.html'>Reference</a>
<a class='wikilink' href='http://arduino.cc/en/Main/Hardware'>Hardware</a>
<a class='wikilink' href='FAQ.html'>FAQ</a>
</p>
<p class='vspace'></p>
</div>
</div>
<!--/PageLeftFmt-->
<div id="pagetext">
<!--PageText-->
<div id='wikitext'>
<p><strong>Reference</strong> &nbsp; <a class='wikilink' href='index.html'>Language</a> | <a class='wikilink' href='Libraries.html'>Libraries</a> | <a class='wikilink' href='Comparison.html'>Comparison</a> | <a class='wikilink' href='Changes.html'>Changes</a>
</p>
<p class='vspace'></p><h2>constants</h2>
<p>Constants are predefined variables in the Arduino language. They are used to make the programs easier to read. We classify constants in groups.
</p>
<p class='vspace'></p><h3>Defining Logical Levels, true and false (Boolean Constants)</h3>
<p>There are two constants used to represent truth and falsity in the Arduino language: <strong>true</strong>, and <strong>false</strong>.
</p>
<p class='vspace'></p><h4>false</h4>
<p>false is the easier of the two to define. false is defined as 0 (zero).
</p>
<p class='vspace'></p><h4>true</h4>
<p>true is often said to be defined as 1, which is correct, but true has a wider definition. Any integer which is <em>non-zero</em> is TRUE, in a Boolean sense. So -1, 2 and -200 are all defined as true, too, in a Boolean sense.
</p>
<p class='vspace'></p><p>Note that the <em>true</em> and <em>false</em> constants are typed in lowercase unlike HIGH, LOW, INPUT, &amp; OUTPUT.
</p>
<p class='vspace'></p><h3>Defining Pin Levels, HIGH and LOW</h3>
<p>When reading or writing to a digital pin there are only two possible values a pin can take/be-set-to: <strong>HIGH</strong> and <strong>LOW</strong>.
</p>
<p class='vspace'></p><p><strong>HIGH</strong>
</p>
<p class='vspace'></p><p>The meaning of HIGH (in reference to a pin) is somewhat different depending on whether a pin is set to an INPUT or OUTPUT.
When a pin is configured as an INPUT with pinMode, and read with digitalRead, the microcontroller will report HIGH if a voltage of 3 volts or more is present at the pin.
</p>
<p class='vspace'></p><p>A pin may also be configured as an INPUT with pinMode, and subsequently made HIGH with digitalWrite, this will set the internal 20K pullup resistors, which will <em>steer</em> the input pin to a HIGH reading unless it is pulled LOW by external circuitry.
</p>
<p class='vspace'></p><p>When a pin is configured to OUTPUT with pinMode, and set to HIGH with digitalWrite, the pin is at 5 volts. In this state it can <em>source</em> current, e.g. light an LED that is connected through a series resistor to ground, or to another pin configured as an output, and set to LOW.
</p>
<p class='vspace'></p><p><strong>LOW</strong>
</p>
<p class='vspace'></p><p>The meaning of LOW also has a different meaning depending on whether a pin is set to INPUT or OUTPUT. When a pin is configured as an INPUT with pinMode, and read with digitalRead, the microcontroller will report LOW if a voltage of 2 volts or less is present at the pin.
</p>
<p class='vspace'></p><p>When a pin is configured to OUTPUT with pinMode, and set to LOW with digitalWrite, the pin is at 0 volts. In this state it can <em>sink</em> current, e.g. light an LED that is connected through a series resistor to, +5 volts, or to another pin configured as an output, and set to HIGH.
</p>
<p class='vspace'></p><h3>Defining Digital Pins, INPUT and OUTPUT</h3>
<p>Digital pins can be used either as <strong>INPUT</strong> or <strong>OUTPUT</strong>. Changing a pin from INPUT TO OUTPUT with pinMode() drastically changes the electrical behavior of the pin.
</p>
<p class='vspace'></p><h4>Pins Configured as Inputs</h4>
<p>Arduino (Atmega) pins configured as <strong>INPUT</strong> with pinMode() are said to be in a high-impedance state. One way of explaining this is that pins configured as INPUT make extremely small demands on the circuit that they are sampling, say equivalent to a series resistor of 100 Megohms in front of the pin. This makes them useful for reading a sensor, but not powering an LED.
</p>
<p class='vspace'></p><h4>Pins Configured as Outputs</h4>
<p>Pins configured as <strong>OUTPUT</strong> with pinMode() are said to be in a low-impedance state. This means that they can provide a substantial amount of current to other circuits. Atmega pins can source (provide positive current) or sink (provide negative current) up to 40 mA (milliamps) of current to other devices/circuits. This makes them useful for powering LED's but useless for reading sensors. Pins configured as outputs can also be damaged or destroyed if short circuited to either ground or 5 volt power rails. The amount of current provided by an Atmega pin is also not enough to power most relays or motors, and some interface circuitry will be required.
</p>
<p class='vspace'></p><h4>See also</h4>
<ul><li><a class='wikilink' href='PinMode.html'>pinMode()</a>
</li><li><a class='wikilink' href='IntegerConstants.html'>Integer Constants</a>
</li><li><a class='wikilink' href='BooleanVariables.html'>boolean variables</a>
</li></ul><p class='vspace'></p><p><a class='wikilink' href='index.html'>Reference Home</a>
</p>
<p class='vspace'></p><p><em>Corrections, suggestions, and new documentation should be posted to the <a class='urllink' href='http://arduino.cc/forum/index.php/board,23.0.html' rel='nofollow'>Forum</a>.</em>
</p>
<p class='vspace'></p><p>The text of the Arduino reference is licensed under a
<a class='urllink' href='http://creativecommons.org/licenses/by-sa/3.0/' rel='nofollow'>Creative Commons Attribution-ShareAlike 3.0 License</a>. Code samples in the reference are released into the public domain.
</p>
</div>
</div>
<!--PageFooterFmt-->
<div id="pagefooter">
&copy;Arduino |
<a href='#'>Edit Page</a> | <a href='#'>Page History</a> | <a href='#' target='_blank'>Printable View</a> | <a href='http://arduino.cc/en/Site/AllRecentChanges'>All Recent Site Changes</a>
</div>
<!--/PageFooterFmt-->
</div>
</body>
</html>

View File

@@ -0,0 +1,115 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>Arduino Reference - Constrain </title>
<link rel="shortcut icon" type="image/x-icon" href="http://arduino.cc/en/favicon.png">
<link rel='stylesheet' href='arduinoWideRender.css'
type='text/css' />
<!--HeaderText--><style type='text/css'><!--
ul, ol, pre, dl, p { margin-top:0px; margin-bottom:0px; }
code { white-space: nowrap; }
.vspace { margin-top:1.33em; }
.indent { margin-left:40px; }
.outdent { margin-left:40px; text-indent:-40px; }
a.createlinktext { text-decoration:none; border-bottom:1px dotted gray; }
a.createlink { text-decoration:none; position:relative; top:-0.5em;
font-weight:bold; font-size:smaller; border-bottom:none; }
img { border:0px; }
.editconflict { color:green;
font-style:italic; margin-top:1.33em; margin-bottom:1.33em; }
table.markup { border: 2px dotted #ccf; width:90%; }
td.markup1, td.markup2 { padding-left:10px; padding-right:10px; }
td.markup1 { border-bottom: 1px solid #ccf; }
div.faq { margin-left:2em; }
div.faq p.question { margin: 1em 0 0.75em -2em; font-weight:bold; }
div.faq hr { margin-left: -2em; }
.frame
{ border:1px solid #cccccc; padding:4px; background-color:#f9f9f9; }
.lfloat { float:left; margin-right:0.5em; }
.rfloat { float:right; margin-left:0.5em; }
a.varlink { text-decoration:none; }
--></style> <meta name='robots' content='index,follow' />
<meta name="verify-v1" content="TtxFIEJAB6zdJ509wLxjnapQzKAMNm9u0Wj4ho6wxIY=" />
</head>
<body>
<div id="page">
<!--PageHeaderFmt-->
<div id="pageheader">
<div class="title"><a href='http://arduino.cc/en'>Arduino</a></div>
</div>
<!--/PageHeaderFmt-->
<!--PageLeftFmt-->
<div id="pagenav">
<div id="navbar">
<p><a class='wikilink' href='http://arduino.cc/en/Main/Buy'>Buy</a>
<a class='wikilink' href='http://arduino.cc/en/Main/Software'>Download</a>
<a class='wikilink' href='Guide_index.html'>Getting Started</a>
<a class='wikilink' href='http://arduino.cc/en/Tutorial/HomePage'>Learning</a>
<a class='wikilink' href='index.html'>Reference</a>
<a class='wikilink' href='http://arduino.cc/en/Main/Hardware'>Hardware</a>
<a class='wikilink' href='FAQ.html'>FAQ</a>
</p>
<p class='vspace'></p>
</div>
</div>
<!--/PageLeftFmt-->
<div id="pagetext">
<!--PageText-->
<div id='wikitext'>
<p><strong>Reference</strong> &nbsp; <a class='wikilink' href='index.html'>Language</a> | <a class='wikilink' href='Libraries.html'>Libraries</a> | <a class='wikilink' href='Comparison.html'>Comparison</a> | <a class='wikilink' href='Changes.html'>Changes</a>
</p>
<p class='vspace'></p><h2>constrain(x, a, b)</h2>
<h4>Description</h4>
<p>Constrains a number to be within a range.
</p>
<p class='vspace'></p><h4>Parameters</h4>
<p>x: the number to constrain, all data types
</p>
<p class='vspace'></p><p>a: the lower end of the range, all data types
</p>
<p class='vspace'></p><p>b: the upper end of the range, all data types
</p>
<p class='vspace'></p><h4>Returns</h4>
<p><strong>x</strong>: if <strong>x</strong> is between <strong>a</strong> and <strong>b</strong>
</p>
<p class='vspace'></p><p><strong>a</strong>: if <strong>x</strong> is less than <strong>a</strong>
</p>
<p class='vspace'></p><p><strong>b</strong>: if <strong>x</strong> is greater than <strong>b</strong>
</p>
<p class='vspace'></p><h4>Example</h4>
<pre>sensVal = constrain(sensVal, 10, 150);
// limits range of sensor values to between 10 and 150
</pre>
<p class='vspace'></p><h4>See also</h4>
<ul><li><a class='wikilink' href='Min.html'>min</a>()
</li><li><a class='wikilink' href='Max.html'>max</a>()
</li></ul><p class='vspace'></p><p><a class='wikilink' href='index.html'>Reference Home</a>
</p>
<p class='vspace'></p><p><em>Corrections, suggestions, and new documentation should be posted to the <a class='urllink' href='http://arduino.cc/forum/index.php/board,23.0.html' rel='nofollow'>Forum</a>.</em>
</p>
<p class='vspace'></p><p>The text of the Arduino reference is licensed under a
<a class='urllink' href='http://creativecommons.org/licenses/by-sa/3.0/' rel='nofollow'>Creative Commons Attribution-ShareAlike 3.0 License</a>. Code samples in the reference are released into the public domain.
</p>
</div>
</div>
<!--PageFooterFmt-->
<div id="pagefooter">
&copy;Arduino |
<a href='#'>Edit Page</a> | <a href='#'>Page History</a> | <a href='#' target='_blank'>Printable View</a> | <a href='http://arduino.cc/en/Site/AllRecentChanges'>All Recent Site Changes</a>
</div>
<!--/PageFooterFmt-->
</div>
</body>
</html>

View File

@@ -0,0 +1,107 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>Arduino Reference - Continue </title>
<link rel="shortcut icon" type="image/x-icon" href="http://arduino.cc/en/favicon.png">
<link rel='stylesheet' href='arduinoWideRender.css'
type='text/css' />
<!--HeaderText--><style type='text/css'><!--
ul, ol, pre, dl, p { margin-top:0px; margin-bottom:0px; }
code { white-space: nowrap; }
.vspace { margin-top:1.33em; }
.indent { margin-left:40px; }
.outdent { margin-left:40px; text-indent:-40px; }
a.createlinktext { text-decoration:none; border-bottom:1px dotted gray; }
a.createlink { text-decoration:none; position:relative; top:-0.5em;
font-weight:bold; font-size:smaller; border-bottom:none; }
img { border:0px; }
.editconflict { color:green;
font-style:italic; margin-top:1.33em; margin-bottom:1.33em; }
table.markup { border: 2px dotted #ccf; width:90%; }
td.markup1, td.markup2 { padding-left:10px; padding-right:10px; }
td.markup1 { border-bottom: 1px solid #ccf; }
div.faq { margin-left:2em; }
div.faq p.question { margin: 1em 0 0.75em -2em; font-weight:bold; }
div.faq hr { margin-left: -2em; }
.frame
{ border:1px solid #cccccc; padding:4px; background-color:#f9f9f9; }
.lfloat { float:left; margin-right:0.5em; }
.rfloat { float:right; margin-left:0.5em; }
a.varlink { text-decoration:none; }
--></style> <meta name='robots' content='index,follow' />
<meta name="verify-v1" content="TtxFIEJAB6zdJ509wLxjnapQzKAMNm9u0Wj4ho6wxIY=" />
</head>
<body>
<div id="page">
<!--PageHeaderFmt-->
<div id="pageheader">
<div class="title"><a href='http://arduino.cc/en'>Arduino</a></div>
</div>
<!--/PageHeaderFmt-->
<!--PageLeftFmt-->
<div id="pagenav">
<div id="navbar">
<p><a class='wikilink' href='http://arduino.cc/en/Main/Buy'>Buy</a>
<a class='wikilink' href='http://arduino.cc/en/Main/Software'>Download</a>
<a class='wikilink' href='Guide_index.html'>Getting Started</a>
<a class='wikilink' href='http://arduino.cc/en/Tutorial/HomePage'>Learning</a>
<a class='wikilink' href='index.html'>Reference</a>
<a class='wikilink' href='http://arduino.cc/en/Main/Hardware'>Hardware</a>
<a class='wikilink' href='FAQ.html'>FAQ</a>
</p>
<p class='vspace'></p>
</div>
</div>
<!--/PageLeftFmt-->
<div id="pagetext">
<!--PageText-->
<div id='wikitext'>
<p><strong>Reference</strong> &nbsp; <a class='wikilink' href='index.html'>Language</a> | <a class='wikilink' href='Libraries.html'>Libraries</a> | <a class='wikilink' href='Comparison.html'>Comparison</a> | <a class='wikilink' href='Changes.html'>Changes</a>
</p>
<p class='vspace'></p><h2>continue</h2>
<p>The continue statement skips the rest of the current iteration of a loop (<strong>do</strong>, <strong>for</strong>, or <strong>while</strong>). It continues by checking the conditional expression of the loop, and proceeding with any subsequent iterations.
</p>
<p class='vspace'></p><h4>Example</h4>
<pre>
for (x = 0; x &lt; 255; x ++)
{
if (x &gt; 40 &amp;&amp; x &lt; 120){ // create jump in values
continue;
}
digitalWrite(PWMpin, x);
delay(50);
}
</pre>
<p class='vspace'></p><p><a class='wikilink' href='index.html'>Reference Home</a>
</p>
<p class='vspace'></p><p><em>Corrections, suggestions, and new documentation should be posted to the <a class='urllink' href='http://arduino.cc/forum/index.php/board,23.0.html' rel='nofollow'>Forum</a>.</em>
</p>
<p class='vspace'></p><p>The text of the Arduino reference is licensed under a
<a class='urllink' href='http://creativecommons.org/licenses/by-sa/3.0/' rel='nofollow'>Creative Commons Attribution-ShareAlike 3.0 License</a>. Code samples in the reference are released into the public domain.
</p>
</div>
</div>
<!--PageFooterFmt-->
<div id="pagefooter">
&copy;Arduino |
<a href='#'>Edit Page</a> | <a href='#'>Page History</a> | <a href='#' target='_blank'>Printable View</a> | <a href='http://arduino.cc/en/Site/AllRecentChanges'>All Recent Site Changes</a>
</div>
<!--/PageFooterFmt-->
</div>
</body>
</html>

View File

@@ -0,0 +1,104 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>Arduino Reference - Cos </title>
<link rel="shortcut icon" type="image/x-icon" href="http://arduino.cc/en/favicon.png">
<link rel='stylesheet' href='arduinoWideRender.css'
type='text/css' />
<!--HeaderText--><style type='text/css'><!--
ul, ol, pre, dl, p { margin-top:0px; margin-bottom:0px; }
code { white-space: nowrap; }
.vspace { margin-top:1.33em; }
.indent { margin-left:40px; }
.outdent { margin-left:40px; text-indent:-40px; }
a.createlinktext { text-decoration:none; border-bottom:1px dotted gray; }
a.createlink { text-decoration:none; position:relative; top:-0.5em;
font-weight:bold; font-size:smaller; border-bottom:none; }
img { border:0px; }
.editconflict { color:green;
font-style:italic; margin-top:1.33em; margin-bottom:1.33em; }
table.markup { border: 2px dotted #ccf; width:90%; }
td.markup1, td.markup2 { padding-left:10px; padding-right:10px; }
td.markup1 { border-bottom: 1px solid #ccf; }
div.faq { margin-left:2em; }
div.faq p.question { margin: 1em 0 0.75em -2em; font-weight:bold; }
div.faq hr { margin-left: -2em; }
.frame
{ border:1px solid #cccccc; padding:4px; background-color:#f9f9f9; }
.lfloat { float:left; margin-right:0.5em; }
.rfloat { float:right; margin-left:0.5em; }
a.varlink { text-decoration:none; }
--></style> <meta name='robots' content='index,follow' />
<meta name="verify-v1" content="TtxFIEJAB6zdJ509wLxjnapQzKAMNm9u0Wj4ho6wxIY=" />
</head>
<body>
<div id="page">
<!--PageHeaderFmt-->
<div id="pageheader">
<div class="title"><a href='http://arduino.cc/en'>Arduino</a></div>
</div>
<!--/PageHeaderFmt-->
<!--PageLeftFmt-->
<div id="pagenav">
<div id="navbar">
<p><a class='wikilink' href='http://arduino.cc/en/Main/Buy'>Buy</a>
<a class='wikilink' href='http://arduino.cc/en/Main/Software'>Download</a>
<a class='wikilink' href='Guide_index.html'>Getting Started</a>
<a class='wikilink' href='http://arduino.cc/en/Tutorial/HomePage'>Learning</a>
<a class='wikilink' href='index.html'>Reference</a>
<a class='wikilink' href='http://arduino.cc/en/Main/Hardware'>Hardware</a>
<a class='wikilink' href='FAQ.html'>FAQ</a>
</p>
<p class='vspace'></p>
</div>
</div>
<!--/PageLeftFmt-->
<div id="pagetext">
<!--PageText-->
<div id='wikitext'>
<p><strong>Reference</strong> &nbsp; <a class='wikilink' href='index.html'>Language</a> | <a class='wikilink' href='Libraries.html'>Libraries</a> | <a class='wikilink' href='Comparison.html'>Comparison</a> | <a class='wikilink' href='Changes.html'>Changes</a>
</p>
<p class='vspace'></p><h2>cos(rad)</h2>
<h4>Description</h4>
<p>Calculates the cos of an angle (in radians). The result will be between -1 and 1.<br />
</p><h4>Parameters</h4>
<p>rad: the angle in radians (<em>float</em>)
</p>
<p class='vspace'></p><h4>Returns</h4>
<p>The cos of the angle ("double")
</p>
<p class='vspace'></p><h4>See also</h4>
<ul><li><a class='wikilink' href='Sin.html'>sin</a>()
</li><li><a class='wikilink' href='Tan.html'>tan</a>()
</li><li><a class='wikilink' href='Float.html'>float</a>
</li><li><a class='wikilink' href='Double.html'>double</a>
</li></ul><p class='vspace'></p><p><a class='wikilink' href='index.html'>Reference Home</a>
</p>
<p class='vspace'></p><p><em>Corrections, suggestions, and new documentation should be posted to the <a class='urllink' href='http://arduino.cc/forum/index.php/board,23.0.html' rel='nofollow'>Forum</a>.</em>
</p>
<p class='vspace'></p><p>The text of the Arduino reference is licensed under a
<a class='urllink' href='http://creativecommons.org/licenses/by-sa/3.0/' rel='nofollow'>Creative Commons Attribution-ShareAlike 3.0 License</a>. Code samples in the reference are released into the public domain.
</p>
</div>
</div>
<!--PageFooterFmt-->
<div id="pagefooter">
&copy;Arduino |
<a href='#'>Edit Page</a> | <a href='#'>Page History</a> | <a href='#' target='_blank'>Printable View</a> | <a href='http://arduino.cc/en/Site/AllRecentChanges'>All Recent Site Changes</a>
</div>
<!--/PageFooterFmt-->
</div>
</body>
</html>

View File

@@ -0,0 +1,122 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>Arduino Reference - Define </title>
<link rel="shortcut icon" type="image/x-icon" href="http://arduino.cc/en/favicon.png">
<link rel='stylesheet' href='arduinoWideRender.css'
type='text/css' />
<!--HeaderText--><style type='text/css'><!--
ul, ol, pre, dl, p { margin-top:0px; margin-bottom:0px; }
code { white-space: nowrap; }
.vspace { margin-top:1.33em; }
.indent { margin-left:40px; }
.outdent { margin-left:40px; text-indent:-40px; }
a.createlinktext { text-decoration:none; border-bottom:1px dotted gray; }
a.createlink { text-decoration:none; position:relative; top:-0.5em;
font-weight:bold; font-size:smaller; border-bottom:none; }
img { border:0px; }
.editconflict { color:green;
font-style:italic; margin-top:1.33em; margin-bottom:1.33em; }
table.markup { border: 2px dotted #ccf; width:90%; }
td.markup1, td.markup2 { padding-left:10px; padding-right:10px; }
td.markup1 { border-bottom: 1px solid #ccf; }
div.faq { margin-left:2em; }
div.faq p.question { margin: 1em 0 0.75em -2em; font-weight:bold; }
div.faq hr { margin-left: -2em; }
.frame
{ border:1px solid #cccccc; padding:4px; background-color:#f9f9f9; }
.lfloat { float:left; margin-right:0.5em; }
.rfloat { float:right; margin-left:0.5em; }
a.varlink { text-decoration:none; }
--></style> <meta name='robots' content='index,follow' />
<meta name="verify-v1" content="TtxFIEJAB6zdJ509wLxjnapQzKAMNm9u0Wj4ho6wxIY=" />
</head>
<body>
<div id="page">
<!--PageHeaderFmt-->
<div id="pageheader">
<div class="title"><a href='http://arduino.cc/en'>Arduino</a></div>
</div>
<!--/PageHeaderFmt-->
<!--PageLeftFmt-->
<div id="pagenav">
<div id="navbar">
<p><a class='wikilink' href='http://arduino.cc/en/Main/Buy'>Buy</a>
<a class='wikilink' href='http://arduino.cc/en/Main/Software'>Download</a>
<a class='wikilink' href='Guide_index.html'>Getting Started</a>
<a class='wikilink' href='http://arduino.cc/en/Tutorial/HomePage'>Learning</a>
<a class='wikilink' href='index.html'>Reference</a>
<a class='wikilink' href='http://arduino.cc/en/Main/Hardware'>Hardware</a>
<a class='wikilink' href='FAQ.html'>FAQ</a>
</p>
<p class='vspace'></p>
</div>
</div>
<!--/PageLeftFmt-->
<div id="pagetext">
<!--PageText-->
<div id='wikitext'>
<p><strong>Reference</strong> &nbsp; <a class='wikilink' href='index.html'>Language</a> | <a class='wikilink' href='Libraries.html'>Libraries</a> | <a class='wikilink' href='Comparison.html'>Comparison</a> | <a class='wikilink' href='Changes.html'>Changes</a>
</p>
<p class='vspace'></p><h2>Define</h2>
<p><code>#define</code> is a useful C component that allows the programmer to give a name to a constant value before the program is compiled. Defined constants in arduino don't take up any program memory space on the chip. The compiler will replace references to these constants with the defined value at compile time.
</p>
<p class='vspace'></p><p>This can have some unwanted side effects though, if for example, a constant name that had been #defined is included in some other constant or variable name. In that case the text would be replaced by the #defined number (or text).
</p>
<p class='vspace'></p><p>In general, the <em><a class='wikilink' href='Const.html'>const</a></em> keyword is preferred for defining constants and should be used instead of #define.
</p>
<p class='vspace'></p><p>Arduino defines have the same syntax as C defines:
</p>
<p class='vspace'></p><h4>Syntax</h4>
<p><code>#define constantName value</code>
</p>
<p class='vspace'></p><p>Note that the # is necessary.
</p>
<p class='vspace'></p><h4>Example</h4>
<pre>#define ledPin 3
// The compiler will replace any mention of ledPin with the value 3 at compile time.
</pre>
<p class='vspace'></p><h4>Tip</h4>
<p>There is no semicolon after the #define statement. If you include one, the compiler will throw cryptic errors further down the page.
</p>
<p class='vspace'></p><pre>#define ledPin 3; // this is an error
</pre>
<p class='vspace'></p><p>Similarly, including an equal sign after the #define statement will also generate a cryptic compiler error further down the page.
</p>
<p class='vspace'></p><pre>#define ledPin = 3 // this is also an error
</pre>
<p class='vspace'></p><h4>See</h4>
<ul><li><a class='wikilink' href='Const.html'>const</a>
</li><li><a class='wikilink' href='IntegerConstants.html'>Constants</a>
</li></ul><p><a class='wikilink' href='index.html'>Reference Home</a>
</p>
<p class='vspace'></p><p><em>Corrections, suggestions, and new documentation should be posted to the <a class='urllink' href='http://arduino.cc/forum/index.php/board,23.0.html' rel='nofollow'>Forum</a>.</em>
</p>
<p class='vspace'></p><p>The text of the Arduino reference is licensed under a
<a class='urllink' href='http://creativecommons.org/licenses/by-sa/3.0/' rel='nofollow'>Creative Commons Attribution-ShareAlike 3.0 License</a>. Code samples in the reference are released into the public domain.
</p>
</div>
</div>
<!--PageFooterFmt-->
<div id="pagefooter">
&copy;Arduino |
<a href='#'>Edit Page</a> | <a href='#'>Page History</a> | <a href='#' target='_blank'>Printable View</a> | <a href='http://arduino.cc/en/Site/AllRecentChanges'>All Recent Site Changes</a>
</div>
<!--/PageFooterFmt-->
</div>
</body>
</html>

View File

@@ -0,0 +1,131 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>Arduino Reference - Delay </title>
<link rel="shortcut icon" type="image/x-icon" href="http://arduino.cc/en/favicon.png">
<link rel='stylesheet' href='arduinoWideRender.css'
type='text/css' />
<!--HeaderText--><style type='text/css'><!--
ul, ol, pre, dl, p { margin-top:0px; margin-bottom:0px; }
code { white-space: nowrap; }
.vspace { margin-top:1.33em; }
.indent { margin-left:40px; }
.outdent { margin-left:40px; text-indent:-40px; }
a.createlinktext { text-decoration:none; border-bottom:1px dotted gray; }
a.createlink { text-decoration:none; position:relative; top:-0.5em;
font-weight:bold; font-size:smaller; border-bottom:none; }
img { border:0px; }
.editconflict { color:green;
font-style:italic; margin-top:1.33em; margin-bottom:1.33em; }
table.markup { border: 2px dotted #ccf; width:90%; }
td.markup1, td.markup2 { padding-left:10px; padding-right:10px; }
td.markup1 { border-bottom: 1px solid #ccf; }
div.faq { margin-left:2em; }
div.faq p.question { margin: 1em 0 0.75em -2em; font-weight:bold; }
div.faq hr { margin-left: -2em; }
.frame
{ border:1px solid #cccccc; padding:4px; background-color:#f9f9f9; }
.lfloat { float:left; margin-right:0.5em; }
.rfloat { float:right; margin-left:0.5em; }
a.varlink { text-decoration:none; }
--></style> <meta name='robots' content='index,follow' />
<meta name="verify-v1" content="TtxFIEJAB6zdJ509wLxjnapQzKAMNm9u0Wj4ho6wxIY=" />
</head>
<body>
<div id="page">
<!--PageHeaderFmt-->
<div id="pageheader">
<div class="title"><a href='http://arduino.cc/en'>Arduino</a></div>
</div>
<!--/PageHeaderFmt-->
<!--PageLeftFmt-->
<div id="pagenav">
<div id="navbar">
<p><a class='wikilink' href='http://arduino.cc/en/Main/Buy'>Buy</a>
<a class='wikilink' href='http://arduino.cc/en/Main/Software'>Download</a>
<a class='wikilink' href='Guide_index.html'>Getting Started</a>
<a class='wikilink' href='http://arduino.cc/en/Tutorial/HomePage'>Learning</a>
<a class='wikilink' href='index.html'>Reference</a>
<a class='wikilink' href='http://arduino.cc/en/Main/Hardware'>Hardware</a>
<a class='wikilink' href='FAQ.html'>FAQ</a>
</p>
<p class='vspace'></p>
</div>
</div>
<!--/PageLeftFmt-->
<div id="pagetext">
<!--PageText-->
<div id='wikitext'>
<p><strong>Reference</strong> &nbsp; <a class='wikilink' href='index.html'>Language</a> | <a class='wikilink' href='Libraries.html'>Libraries</a> | <a class='wikilink' href='Comparison.html'>Comparison</a> | <a class='wikilink' href='Changes.html'>Changes</a>
</p>
<p class='vspace'></p><h2>delay()</h2>
<h4>Description</h4>
<p>Pauses the program for the amount of time (in miliseconds) specified as parameter. (There are 1000 milliseconds in a second.)
</p>
<p class='vspace'></p><h4>Syntax</h4>
<p>delay(ms)
</p>
<p class='vspace'></p><h4>Parameters</h4>
<p>ms: the number of milliseconds to pause (<em>unsigned long</em>)
</p>
<p class='vspace'></p><h4>Returns</h4>
<p>nothing
</p>
<p class='vspace'></p><h4>Example</h4>
<pre>
int ledPin = 13; // LED connected to digital pin 13
void setup()
{
pinMode(ledPin, OUTPUT); // sets the digital pin as output
}
void loop()
{
digitalWrite(ledPin, HIGH); // sets the LED on
delay(1000); // waits for a second
digitalWrite(ledPin, LOW); // sets the LED off
delay(1000); // waits for a second
}
</pre>
<p class='vspace'></p><h4>Caveat</h4>
<p>While it is easy to create a blinking LED with the delay() function, and many sketches use short delays for such tasks as switch debouncing, the use of delay() in a sketch has significant drawbacks. No other reading of sensors, mathematical calculations, or pin manipulation can go on during the delay function, so in effect, it brings most other activity to a halt. For alternative approaches to controlling timing see the <a class='wikilink' href='Millis.html'>millis()</a> function and the sketch sited below. More knowledgeable programmers usually avoid the use of delay() for timing of events longer than 10's of milliseconds unless the Arduino sketch is very simple.
</p>
<p class='vspace'></p><p>Certain things <em>do</em> go on while the delay() function is controlling the Atmega chip however, because the delay function does not disable interrupts. Serial communication that appears at the RX pin is recorded, PWM (<a class='wikilink' href='AnalogWrite.html'>analogWrite</a>) values and pin states are maintained, and <a class='wikilink' href='AttachInterrupt.html'>interrupts</a> will work as they should.
</p>
<p class='vspace'></p><h4>See also</h4>
<ul><li><a class='wikilink' href='Millis.html'>millis</a>()
</li><li><a class='wikilink' href='Micros.html'>micros</a>()
</li><li><a class='wikilink' href='DelayMicroseconds.html'>delayMicroseconds</a>()
</li><li><a class='wikilink' href='http://arduino.cc/en/Tutorial/BlinkWithoutDelay'>Blink Without Delay</a> example
</li></ul><p class='vspace'></p><p><a class='wikilink' href='index.html'>Reference Home</a>
</p>
<p class='vspace'></p><p><em>Corrections, suggestions, and new documentation should be posted to the <a class='urllink' href='http://arduino.cc/forum/index.php/board,23.0.html' rel='nofollow'>Forum</a>.</em>
</p>
<p class='vspace'></p><p>The text of the Arduino reference is licensed under a
<a class='urllink' href='http://creativecommons.org/licenses/by-sa/3.0/' rel='nofollow'>Creative Commons Attribution-ShareAlike 3.0 License</a>. Code samples in the reference are released into the public domain.
</p>
</div>
</div>
<!--PageFooterFmt-->
<div id="pagefooter">
&copy;Arduino |
<a href='#'>Edit Page</a> | <a href='#'>Page History</a> | <a href='#' target='_blank'>Printable View</a> | <a href='http://arduino.cc/en/Site/AllRecentChanges'>All Recent Site Changes</a>
</div>
<!--/PageFooterFmt-->
</div>
</body>
</html>

View File

@@ -0,0 +1,134 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>Arduino Reference - DelayMicroseconds </title>
<link rel="shortcut icon" type="image/x-icon" href="http://arduino.cc/en/favicon.png">
<link rel='stylesheet' href='arduinoWideRender.css'
type='text/css' />
<!--HeaderText--><style type='text/css'><!--
ul, ol, pre, dl, p { margin-top:0px; margin-bottom:0px; }
code { white-space: nowrap; }
.vspace { margin-top:1.33em; }
.indent { margin-left:40px; }
.outdent { margin-left:40px; text-indent:-40px; }
a.createlinktext { text-decoration:none; border-bottom:1px dotted gray; }
a.createlink { text-decoration:none; position:relative; top:-0.5em;
font-weight:bold; font-size:smaller; border-bottom:none; }
img { border:0px; }
.editconflict { color:green;
font-style:italic; margin-top:1.33em; margin-bottom:1.33em; }
table.markup { border: 2px dotted #ccf; width:90%; }
td.markup1, td.markup2 { padding-left:10px; padding-right:10px; }
td.markup1 { border-bottom: 1px solid #ccf; }
div.faq { margin-left:2em; }
div.faq p.question { margin: 1em 0 0.75em -2em; font-weight:bold; }
div.faq hr { margin-left: -2em; }
.frame
{ border:1px solid #cccccc; padding:4px; background-color:#f9f9f9; }
.lfloat { float:left; margin-right:0.5em; }
.rfloat { float:right; margin-left:0.5em; }
a.varlink { text-decoration:none; }
--></style> <meta name='robots' content='index,follow' />
<meta name="verify-v1" content="TtxFIEJAB6zdJ509wLxjnapQzKAMNm9u0Wj4ho6wxIY=" />
</head>
<body>
<div id="page">
<!--PageHeaderFmt-->
<div id="pageheader">
<div class="title"><a href='http://arduino.cc/en'>Arduino</a></div>
</div>
<!--/PageHeaderFmt-->
<!--PageLeftFmt-->
<div id="pagenav">
<div id="navbar">
<p><a class='wikilink' href='http://arduino.cc/en/Main/Buy'>Buy</a>
<a class='wikilink' href='http://arduino.cc/en/Main/Software'>Download</a>
<a class='wikilink' href='Guide_index.html'>Getting Started</a>
<a class='wikilink' href='http://arduino.cc/en/Tutorial/HomePage'>Learning</a>
<a class='wikilink' href='index.html'>Reference</a>
<a class='wikilink' href='http://arduino.cc/en/Main/Hardware'>Hardware</a>
<a class='wikilink' href='FAQ.html'>FAQ</a>
</p>
<p class='vspace'></p>
</div>
</div>
<!--/PageLeftFmt-->
<div id="pagetext">
<!--PageText-->
<div id='wikitext'>
<p><strong>Reference</strong> &nbsp; <a class='wikilink' href='index.html'>Language</a> | <a class='wikilink' href='Libraries.html'>Libraries</a> | <a class='wikilink' href='Comparison.html'>Comparison</a> | <a class='wikilink' href='Changes.html'>Changes</a>
</p>
<p class='vspace'></p><h2>delayMicroseconds()</h2>
<h4>Description</h4>
<p>Pauses the program for the amount of time (in microseconds) specified as parameter. There are a thousand microseconds in a millisecond, and a million microseconds in a second.
</p>
<p class='vspace'></p><p>Currently, the largest value that will produce an accurate delay is 16383. This could change in future Arduino releases. For delays longer than a few thousand microseconds, you should use delay() instead.
</p>
<p class='vspace'></p><h4>Syntax</h4>
<p>delayMicroseconds(us)
</p>
<p class='vspace'></p><h4>Parameters</h4>
<p>us: the number of microseconds to pause (<em>unsigned int</em>)
</p>
<p class='vspace'></p><h4>Returns</h4>
<p>None
</p>
<p class='vspace'></p><h4>Example</h4>
<pre>
int outPin = 8; // digital pin 8
void setup()
{
pinMode(outPin, OUTPUT); // sets the digital pin as output
}
void loop()
{
digitalWrite(outPin, HIGH); // sets the pin on
delayMicroseconds(50); // pauses for 50 microseconds
digitalWrite(outPin, LOW); // sets the pin off
delayMicroseconds(50); // pauses for 50 microseconds
}
</pre>
<p class='vspace'></p><p>configures pin number 8 to work as an output pin. It sends a train of pulses with 100 microseconds period.
</p>
<p class='vspace'></p><h4>Caveats and Known Issues</h4>
<p>This function works very accurately in the range 3 microseconds and up. We cannot assure that delayMicroseconds will perform precisely for smaller delay-times.
</p>
<p class='vspace'></p><p>As of Arduino 0018, delayMicroseconds() no longer disables interrupts.
</p>
<p class='vspace'></p><h4>See also</h4>
<ul><li><a class='wikilink' href='Millis.html'>millis</a>()
</li><li><a class='wikilink' href='Micros.html'>micros</a>()
</li><li><a class='wikilink' href='Delay.html'>delay</a>()
</li></ul><p><a class='wikilink' href='index.html'>Reference Home</a>
</p>
<p class='vspace'></p><p><em>Corrections, suggestions, and new documentation should be posted to the <a class='urllink' href='http://arduino.cc/forum/index.php/board,23.0.html' rel='nofollow'>Forum</a>.</em>
</p>
<p class='vspace'></p><p>The text of the Arduino reference is licensed under a
<a class='urllink' href='http://creativecommons.org/licenses/by-sa/3.0/' rel='nofollow'>Creative Commons Attribution-ShareAlike 3.0 License</a>. Code samples in the reference are released into the public domain.
</p>
</div>
</div>
<!--PageFooterFmt-->
<div id="pagefooter">
&copy;Arduino |
<a href='#'>Edit Page</a> | <a href='#'>Page History</a> | <a href='#' target='_blank'>Printable View</a> | <a href='http://arduino.cc/en/Site/AllRecentChanges'>All Recent Site Changes</a>
</div>
<!--/PageFooterFmt-->
</div>
</body>
</html>

View File

@@ -0,0 +1,99 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>Arduino Reference - DetachInterrupt </title>
<link rel="shortcut icon" type="image/x-icon" href="http://arduino.cc/en/favicon.png">
<link rel='stylesheet' href='arduinoWideRender.css'
type='text/css' />
<!--HeaderText--><style type='text/css'><!--
ul, ol, pre, dl, p { margin-top:0px; margin-bottom:0px; }
code { white-space: nowrap; }
.vspace { margin-top:1.33em; }
.indent { margin-left:40px; }
.outdent { margin-left:40px; text-indent:-40px; }
a.createlinktext { text-decoration:none; border-bottom:1px dotted gray; }
a.createlink { text-decoration:none; position:relative; top:-0.5em;
font-weight:bold; font-size:smaller; border-bottom:none; }
img { border:0px; }
.editconflict { color:green;
font-style:italic; margin-top:1.33em; margin-bottom:1.33em; }
table.markup { border: 2px dotted #ccf; width:90%; }
td.markup1, td.markup2 { padding-left:10px; padding-right:10px; }
td.markup1 { border-bottom: 1px solid #ccf; }
div.faq { margin-left:2em; }
div.faq p.question { margin: 1em 0 0.75em -2em; font-weight:bold; }
div.faq hr { margin-left: -2em; }
.frame
{ border:1px solid #cccccc; padding:4px; background-color:#f9f9f9; }
.lfloat { float:left; margin-right:0.5em; }
.rfloat { float:right; margin-left:0.5em; }
a.varlink { text-decoration:none; }
--></style> <meta name='robots' content='index,follow' />
<meta name="verify-v1" content="TtxFIEJAB6zdJ509wLxjnapQzKAMNm9u0Wj4ho6wxIY=" />
</head>
<body>
<div id="page">
<!--PageHeaderFmt-->
<div id="pageheader">
<div class="title"><a href='http://arduino.cc/en'>Arduino</a></div>
</div>
<!--/PageHeaderFmt-->
<!--PageLeftFmt-->
<div id="pagenav">
<div id="navbar">
<p><a class='wikilink' href='http://arduino.cc/en/Main/Buy'>Buy</a>
<a class='wikilink' href='http://arduino.cc/en/Main/Software'>Download</a>
<a class='wikilink' href='Guide_index.html'>Getting Started</a>
<a class='wikilink' href='http://arduino.cc/en/Tutorial/HomePage'>Learning</a>
<a class='wikilink' href='index.html'>Reference</a>
<a class='wikilink' href='http://arduino.cc/en/Main/Hardware'>Hardware</a>
<a class='wikilink' href='FAQ.html'>FAQ</a>
</p>
<p class='vspace'></p>
</div>
</div>
<!--/PageLeftFmt-->
<div id="pagetext">
<!--PageText-->
<div id='wikitext'>
<p><strong>Reference</strong> &nbsp; <a class='wikilink' href='index.html'>Language</a> | <a class='wikilink' href='Libraries.html'>Libraries</a> | <a class='wikilink' href='Comparison.html'>Comparison</a> | <a class='wikilink' href='Changes.html'>Changes</a>
</p>
<p class='vspace'></p><h2>detachInterrupt(interrupt)</h2>
<h4>Description</h4>
<p>Turns off the given interrupt.
</p>
<p class='vspace'></p><h4>Parameters</h4>
<p>interrupt: the number of interrupt to disable (0 or 1).
</p>
<p class='vspace'></p><h4>See also</h4>
<ul><li><a class='wikilink' href='AttachInterrupt.html'>attachInterrupt</a>()
</li></ul><p><a class='wikilink' href='index.html'>Reference Home</a>
</p>
<p class='vspace'></p><p><em>Corrections, suggestions, and new documentation should be posted to the <a class='urllink' href='http://arduino.cc/forum/index.php/board,23.0.html' rel='nofollow'>Forum</a>.</em>
</p>
<p class='vspace'></p><p>The text of the Arduino reference is licensed under a
<a class='urllink' href='http://creativecommons.org/licenses/by-sa/3.0/' rel='nofollow'>Creative Commons Attribution-ShareAlike 3.0 License</a>. Code samples in the reference are released into the public domain.
</p>
</div>
</div>
<!--PageFooterFmt-->
<div id="pagefooter">
&copy;Arduino |
<a href='#'>Edit Page</a> | <a href='#'>Page History</a> | <a href='#' target='_blank'>Printable View</a> | <a href='http://arduino.cc/en/Site/AllRecentChanges'>All Recent Site Changes</a>
</div>
<!--/PageFooterFmt-->
</div>
</body>
</html>

View File

@@ -0,0 +1,133 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>Arduino Reference - DigitalRead </title>
<link rel="shortcut icon" type="image/x-icon" href="http://arduino.cc/en/favicon.png">
<link rel='stylesheet' href='arduinoWideRender.css'
type='text/css' />
<!--HeaderText--><style type='text/css'><!--
ul, ol, pre, dl, p { margin-top:0px; margin-bottom:0px; }
code { white-space: nowrap; }
.vspace { margin-top:1.33em; }
.indent { margin-left:40px; }
.outdent { margin-left:40px; text-indent:-40px; }
a.createlinktext { text-decoration:none; border-bottom:1px dotted gray; }
a.createlink { text-decoration:none; position:relative; top:-0.5em;
font-weight:bold; font-size:smaller; border-bottom:none; }
img { border:0px; }
.editconflict { color:green;
font-style:italic; margin-top:1.33em; margin-bottom:1.33em; }
table.markup { border: 2px dotted #ccf; width:90%; }
td.markup1, td.markup2 { padding-left:10px; padding-right:10px; }
td.markup1 { border-bottom: 1px solid #ccf; }
div.faq { margin-left:2em; }
div.faq p.question { margin: 1em 0 0.75em -2em; font-weight:bold; }
div.faq hr { margin-left: -2em; }
.frame
{ border:1px solid #cccccc; padding:4px; background-color:#f9f9f9; }
.lfloat { float:left; margin-right:0.5em; }
.rfloat { float:right; margin-left:0.5em; }
a.varlink { text-decoration:none; }
--></style> <meta name='robots' content='index,follow' />
<meta name="verify-v1" content="TtxFIEJAB6zdJ509wLxjnapQzKAMNm9u0Wj4ho6wxIY=" />
</head>
<body>
<div id="page">
<!--PageHeaderFmt-->
<div id="pageheader">
<div class="title"><a href='http://arduino.cc/en'>Arduino</a></div>
</div>
<!--/PageHeaderFmt-->
<!--PageLeftFmt-->
<div id="pagenav">
<div id="navbar">
<p><a class='wikilink' href='http://arduino.cc/en/Main/Buy'>Buy</a>
<a class='wikilink' href='http://arduino.cc/en/Main/Software'>Download</a>
<a class='wikilink' href='Guide_index.html'>Getting Started</a>
<a class='wikilink' href='http://arduino.cc/en/Tutorial/HomePage'>Learning</a>
<a class='wikilink' href='index.html'>Reference</a>
<a class='wikilink' href='http://arduino.cc/en/Main/Hardware'>Hardware</a>
<a class='wikilink' href='FAQ.html'>FAQ</a>
</p>
<p class='vspace'></p>
</div>
</div>
<!--/PageLeftFmt-->
<div id="pagetext">
<!--PageText-->
<div id='wikitext'>
<p><strong>Reference</strong> &nbsp; <a class='wikilink' href='index.html'>Language</a> | <a class='wikilink' href='Libraries.html'>Libraries</a> | <a class='wikilink' href='Comparison.html'>Comparison</a> | <a class='wikilink' href='Changes.html'>Changes</a>
</p>
<p class='vspace'></p><h2>digitalRead()</h2>
<h4>Description</h4>
<p>Reads the value from a specified digital pin, either <a class='wikilink' href='Constants.html'>HIGH</a> or <a class='wikilink' href='Constants.html'>LOW</a>.
</p>
<p class='vspace'></p><h4>Syntax</h4>
<p>digitalRead(pin)
</p>
<p class='vspace'></p><h4>Parameters</h4>
<p>pin: the number of the digital pin you want to read (<em>int</em>)
</p>
<p class='vspace'></p><h4>Returns</h4>
<p><a class='wikilink' href='Constants.html'>HIGH</a> or <a class='wikilink' href='Constants.html'>LOW</a>
</p>
<p class='vspace'></p><h4>Example</h4>
<pre>
int ledPin = 13; // LED connected to digital pin 13
int inPin = 7; // pushbutton connected to digital pin 7
int val = 0; // variable to store the read value
void setup()
{
pinMode(ledPin, OUTPUT); // sets the digital pin 13 as output
pinMode(inPin, INPUT); // sets the digital pin 7 as input
}
void loop()
{
val = digitalRead(inPin); // read the input pin
digitalWrite(ledPin, val); // sets the LED to the button's value
}
</pre>
<p class='vspace'></p><p>Sets pin 13 to the same value as the pin 7, which is an input.
</p>
<p class='vspace'></p><h4>Note</h4>
<p>If the pin isn't connected to anything, digitalRead() can return either HIGH or LOW (and this can change randomly).
</p>
<p class='vspace'></p><p>The analog input pins can be used as digital pins, referred to as A0, A1, etc.
</p>
<p class='vspace'></p><h4>See also</h4>
<ul><li><a class='wikilink' href='PinMode.html'>pinMode</a>()
</li><li><a class='wikilink' href='DigitalWrite.html'>digitalWrite</a>()
</li><li><a class='wikilink' href='http://arduino.cc/en/Tutorial/DigitalPins'>Tutorial: Digital Pins</a>
</li></ul><p class='vspace'></p><p><a class='wikilink' href='index.html'>Reference Home</a>
</p>
<p class='vspace'></p><p><em>Corrections, suggestions, and new documentation should be posted to the <a class='urllink' href='http://arduino.cc/forum/index.php/board,23.0.html' rel='nofollow'>Forum</a>.</em>
</p>
<p class='vspace'></p><p>The text of the Arduino reference is licensed under a
<a class='urllink' href='http://creativecommons.org/licenses/by-sa/3.0/' rel='nofollow'>Creative Commons Attribution-ShareAlike 3.0 License</a>. Code samples in the reference are released into the public domain.
</p>
</div>
</div>
<!--PageFooterFmt-->
<div id="pagefooter">
&copy;Arduino |
<a href='#'>Edit Page</a> | <a href='#'>Page History</a> | <a href='#' target='_blank'>Printable View</a> | <a href='http://arduino.cc/en/Site/AllRecentChanges'>All Recent Site Changes</a>
</div>
<!--/PageFooterFmt-->
</div>
</body>
</html>

View File

@@ -0,0 +1,138 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>Arduino Reference - DigitalWrite </title>
<link rel="shortcut icon" type="image/x-icon" href="http://arduino.cc/en/favicon.png">
<link rel='stylesheet' href='arduinoWideRender.css'
type='text/css' />
<!--HeaderText--><style type='text/css'><!--
ul, ol, pre, dl, p { margin-top:0px; margin-bottom:0px; }
code { white-space: nowrap; }
.vspace { margin-top:1.33em; }
.indent { margin-left:40px; }
.outdent { margin-left:40px; text-indent:-40px; }
a.createlinktext { text-decoration:none; border-bottom:1px dotted gray; }
a.createlink { text-decoration:none; position:relative; top:-0.5em;
font-weight:bold; font-size:smaller; border-bottom:none; }
img { border:0px; }
.editconflict { color:green;
font-style:italic; margin-top:1.33em; margin-bottom:1.33em; }
table.markup { border: 2px dotted #ccf; width:90%; }
td.markup1, td.markup2 { padding-left:10px; padding-right:10px; }
td.markup1 { border-bottom: 1px solid #ccf; }
div.faq { margin-left:2em; }
div.faq p.question { margin: 1em 0 0.75em -2em; font-weight:bold; }
div.faq hr { margin-left: -2em; }
.frame
{ border:1px solid #cccccc; padding:4px; background-color:#f9f9f9; }
.lfloat { float:left; margin-right:0.5em; }
.rfloat { float:right; margin-left:0.5em; }
a.varlink { text-decoration:none; }
--></style> <meta name='robots' content='index,follow' />
<meta name="verify-v1" content="TtxFIEJAB6zdJ509wLxjnapQzKAMNm9u0Wj4ho6wxIY=" />
</head>
<body>
<div id="page">
<!--PageHeaderFmt-->
<div id="pageheader">
<div class="title"><a href='http://arduino.cc/en'>Arduino</a></div>
</div>
<!--/PageHeaderFmt-->
<!--PageLeftFmt-->
<div id="pagenav">
<div id="navbar">
<p><a class='wikilink' href='http://arduino.cc/en/Main/Buy'>Buy</a>
<a class='wikilink' href='http://arduino.cc/en/Main/Software'>Download</a>
<a class='wikilink' href='Guide_index.html'>Getting Started</a>
<a class='wikilink' href='http://arduino.cc/en/Tutorial/HomePage'>Learning</a>
<a class='wikilink' href='index.html'>Reference</a>
<a class='wikilink' href='http://arduino.cc/en/Main/Hardware'>Hardware</a>
<a class='wikilink' href='FAQ.html'>FAQ</a>
</p>
<p class='vspace'></p>
</div>
</div>
<!--/PageLeftFmt-->
<div id="pagetext">
<!--PageText-->
<div id='wikitext'>
<p><strong>Reference</strong> &nbsp; <a class='wikilink' href='index.html'>Language</a> | <a class='wikilink' href='Libraries.html'>Libraries</a> | <a class='wikilink' href='Comparison.html'>Comparison</a> | <a class='wikilink' href='Changes.html'>Changes</a>
</p>
<p class='vspace'></p><h2>digitalWrite()</h2>
<h4>Description</h4>
<p>Write a <a class='wikilink' href='Constants.html'>HIGH</a> or a <a class='wikilink' href='Constants.html'>LOW</a> value to a digital pin.
</p>
<p class='vspace'></p><p>If the pin has been configured as an OUTPUT with <a class='wikilink' href='PinMode.html'>pinMode</a>(), its voltage will be set to the corresponding value: 5V (or 3.3V on 3.3V boards) for HIGH, 0V (ground) for LOW.
</p>
<p class='vspace'></p><p>If the pin is configured as an INPUT, writing a HIGH value with digitalWrite() will enable an internal 20K pullup resistor (see the <a class='wikilink' href='http://arduino.cc/en/Tutorial/DigitalPins'>tutorial on digital pins</a>). Writing LOW will disable the pullup. The pullup resistor is enough to light an LED dimly, so if <span class='wikiword'>LEDs</span> appear to work, but very dimly, this is a likely cause. The remedy is to set the pin to an output with the pinMode() function.
</p>
<p class='vspace'></p><p><strong>NOTE:</strong> Digital pin 13 is harder to use as a digital input than the other digital pins because it has an LED and resistor attached to it that's soldered to the board on most boards. If you enable its internal 20k pull-up resistor, it will hang at around 1.7 V instead of the expected 5V because the onboard LED and series resistor pull the voltage level down, meaning it always returns LOW. If you must use pin 13 as a digital input, use an external pull down resistor.
</p>
<p class='vspace'></p><h4>Syntax</h4>
<p>digitalWrite(pin, value)
</p>
<p class='vspace'></p><h4>Parameters</h4>
<p>pin: the pin number
</p>
<p class='vspace'></p><p>value: <a class='wikilink' href='Constants.html'>HIGH</a> or <a class='wikilink' href='Constants.html'>LOW</a>
</p>
<p class='vspace'></p><h4>Returns</h4>
<p>none
</p>
<p class='vspace'></p><h4>Example</h4>
<pre>
int ledPin = 13; // LED connected to digital pin 13
void setup()
{
pinMode(ledPin, OUTPUT); // sets the digital pin as output
}
void loop()
{
digitalWrite(ledPin, HIGH); // sets the LED on
delay(1000); // waits for a second
digitalWrite(ledPin, LOW); // sets the LED off
delay(1000); // waits for a second
}
</pre>
<p class='vspace'></p><p>Sets pin 13 to HIGH, makes a one-second-long delay, and sets the pin back to LOW.
</p>
<p class='vspace'></p><h4>Note</h4>
<p>The analog input pins can be used as digital pins, referred to as A0, A1, etc.
</p>
<p class='vspace'></p><h4>See also</h4>
<ul><li><a class='wikilink' href='PinMode.html'>pinMode</a>()
</li><li><a class='wikilink' href='DigitalRead.html'>digitalRead</a>()
</li><li><a class='wikilink' href='http://arduino.cc/en/Tutorial/DigitalPins'>Tutorial: Digital Pins</a>
</li></ul><p class='vspace'></p><p><a class='wikilink' href='index.html'>Reference Home</a>
</p>
<p class='vspace'></p><p><em>Corrections, suggestions, and new documentation should be posted to the <a class='urllink' href='http://arduino.cc/forum/index.php/board,23.0.html' rel='nofollow'>Forum</a>.</em>
</p>
<p class='vspace'></p><p>The text of the Arduino reference is licensed under a
<a class='urllink' href='http://creativecommons.org/licenses/by-sa/3.0/' rel='nofollow'>Creative Commons Attribution-ShareAlike 3.0 License</a>. Code samples in the reference are released into the public domain.
</p>
</div>
</div>
<!--PageFooterFmt-->
<div id="pagefooter">
&copy;Arduino |
<a href='#'>Edit Page</a> | <a href='#'>Page History</a> | <a href='#' target='_blank'>Printable View</a> | <a href='http://arduino.cc/en/Site/AllRecentChanges'>All Recent Site Changes</a>
</div>
<!--/PageFooterFmt-->
</div>
</body>
</html>

View File

@@ -0,0 +1,109 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>Arduino Reference - DoWhile </title>
<link rel="shortcut icon" type="image/x-icon" href="http://arduino.cc/en/favicon.png">
<link rel='stylesheet' href='arduinoWideRender.css'
type='text/css' />
<!--HeaderText--><style type='text/css'><!--
ul, ol, pre, dl, p { margin-top:0px; margin-bottom:0px; }
code { white-space: nowrap; }
.vspace { margin-top:1.33em; }
.indent { margin-left:40px; }
.outdent { margin-left:40px; text-indent:-40px; }
a.createlinktext { text-decoration:none; border-bottom:1px dotted gray; }
a.createlink { text-decoration:none; position:relative; top:-0.5em;
font-weight:bold; font-size:smaller; border-bottom:none; }
img { border:0px; }
.editconflict { color:green;
font-style:italic; margin-top:1.33em; margin-bottom:1.33em; }
table.markup { border: 2px dotted #ccf; width:90%; }
td.markup1, td.markup2 { padding-left:10px; padding-right:10px; }
td.markup1 { border-bottom: 1px solid #ccf; }
div.faq { margin-left:2em; }
div.faq p.question { margin: 1em 0 0.75em -2em; font-weight:bold; }
div.faq hr { margin-left: -2em; }
.frame
{ border:1px solid #cccccc; padding:4px; background-color:#f9f9f9; }
.lfloat { float:left; margin-right:0.5em; }
.rfloat { float:right; margin-left:0.5em; }
a.varlink { text-decoration:none; }
--></style> <meta name='robots' content='index,follow' />
<meta name="verify-v1" content="TtxFIEJAB6zdJ509wLxjnapQzKAMNm9u0Wj4ho6wxIY=" />
</head>
<body>
<div id="page">
<!--PageHeaderFmt-->
<div id="pageheader">
<div class="title"><a href='http://arduino.cc/en'>Arduino</a></div>
</div>
<!--/PageHeaderFmt-->
<!--PageLeftFmt-->
<div id="pagenav">
<div id="navbar">
<p><a class='wikilink' href='http://arduino.cc/en/Main/Buy'>Buy</a>
<a class='wikilink' href='http://arduino.cc/en/Main/Software'>Download</a>
<a class='wikilink' href='Guide_index.html'>Getting Started</a>
<a class='wikilink' href='http://arduino.cc/en/Tutorial/HomePage'>Learning</a>
<a class='wikilink' href='index.html'>Reference</a>
<a class='wikilink' href='http://arduino.cc/en/Main/Hardware'>Hardware</a>
<a class='wikilink' href='FAQ.html'>FAQ</a>
</p>
<p class='vspace'></p>
</div>
</div>
<!--/PageLeftFmt-->
<div id="pagetext">
<!--PageText-->
<div id='wikitext'>
<p><strong>Reference</strong> &nbsp; <a class='wikilink' href='index.html'>Language</a> | <a class='wikilink' href='Libraries.html'>Libraries</a> | <a class='wikilink' href='Comparison.html'>Comparison</a> | <a class='wikilink' href='Changes.html'>Changes</a>
</p>
<p class='vspace'></p><h2>do - while</h2>
<p>The <strong>do</strong> loop works in the same manner as the <strong>while</strong> loop, with the exception that the condition is tested at the end of the loop, so the <strong>do</strong> loop will <em>always</em> run at least once.
</p>
<p class='vspace'></p><pre>
do
{
// statement block
} while (test condition);
</pre>
<p class='vspace'></p><h4>Example</h4>
<pre>
do
{
delay(50); // wait for sensors to stabilize
x = readSensors(); // check the sensors
} while (x &lt; 100);
</pre><p><a class='wikilink' href='index.html'>Reference Home</a>
</p>
<p class='vspace'></p><p><em>Corrections, suggestions, and new documentation should be posted to the <a class='urllink' href='http://arduino.cc/forum/index.php/board,23.0.html' rel='nofollow'>Forum</a>.</em>
</p>
<p class='vspace'></p><p>The text of the Arduino reference is licensed under a
<a class='urllink' href='http://creativecommons.org/licenses/by-sa/3.0/' rel='nofollow'>Creative Commons Attribution-ShareAlike 3.0 License</a>. Code samples in the reference are released into the public domain.
</p>
</div>
</div>
<!--PageFooterFmt-->
<div id="pagefooter">
&copy;Arduino |
<a href='#'>Edit Page</a> | <a href='#'>Page History</a> | <a href='#' target='_blank'>Printable View</a> | <a href='http://arduino.cc/en/Site/AllRecentChanges'>All Recent Site Changes</a>
</div>
<!--/PageFooterFmt-->
</div>
</body>
</html>

View File

@@ -0,0 +1,101 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>Arduino Reference - Double </title>
<link rel="shortcut icon" type="image/x-icon" href="http://arduino.cc/en/favicon.png">
<link rel='stylesheet' href='arduinoWideRender.css'
type='text/css' />
<!--HeaderText--><style type='text/css'><!--
ul, ol, pre, dl, p { margin-top:0px; margin-bottom:0px; }
code { white-space: nowrap; }
.vspace { margin-top:1.33em; }
.indent { margin-left:40px; }
.outdent { margin-left:40px; text-indent:-40px; }
a.createlinktext { text-decoration:none; border-bottom:1px dotted gray; }
a.createlink { text-decoration:none; position:relative; top:-0.5em;
font-weight:bold; font-size:smaller; border-bottom:none; }
img { border:0px; }
.editconflict { color:green;
font-style:italic; margin-top:1.33em; margin-bottom:1.33em; }
table.markup { border: 2px dotted #ccf; width:90%; }
td.markup1, td.markup2 { padding-left:10px; padding-right:10px; }
td.markup1 { border-bottom: 1px solid #ccf; }
div.faq { margin-left:2em; }
div.faq p.question { margin: 1em 0 0.75em -2em; font-weight:bold; }
div.faq hr { margin-left: -2em; }
.frame
{ border:1px solid #cccccc; padding:4px; background-color:#f9f9f9; }
.lfloat { float:left; margin-right:0.5em; }
.rfloat { float:right; margin-left:0.5em; }
a.varlink { text-decoration:none; }
--></style> <meta name='robots' content='index,follow' />
<meta name="verify-v1" content="TtxFIEJAB6zdJ509wLxjnapQzKAMNm9u0Wj4ho6wxIY=" />
</head>
<body>
<div id="page">
<!--PageHeaderFmt-->
<div id="pageheader">
<div class="title"><a href='http://arduino.cc/en'>Arduino</a></div>
</div>
<!--/PageHeaderFmt-->
<!--PageLeftFmt-->
<div id="pagenav">
<div id="navbar">
<p><a class='wikilink' href='http://arduino.cc/en/Main/Buy'>Buy</a>
<a class='wikilink' href='http://arduino.cc/en/Main/Software'>Download</a>
<a class='wikilink' href='Guide_index.html'>Getting Started</a>
<a class='wikilink' href='http://arduino.cc/en/Tutorial/HomePage'>Learning</a>
<a class='wikilink' href='index.html'>Reference</a>
<a class='wikilink' href='http://arduino.cc/en/Main/Hardware'>Hardware</a>
<a class='wikilink' href='FAQ.html'>FAQ</a>
</p>
<p class='vspace'></p>
</div>
</div>
<!--/PageLeftFmt-->
<div id="pagetext">
<!--PageText-->
<div id='wikitext'>
<p><strong>Reference</strong> &nbsp; <a class='wikilink' href='index.html'>Language</a> | <a class='wikilink' href='Libraries.html'>Libraries</a> | <a class='wikilink' href='Comparison.html'>Comparison</a> | <a class='wikilink' href='Changes.html'>Changes</a>
</p>
<p class='vspace'></p><h2>double</h2>
<h4>Desciption</h4>
<p>Double precision floating point number. Occupies 4 bytes.
</p>
<p class='vspace'></p><p>The double implementation on the Arduino is currently exactly the same as the float, with no gain in precision.
</p>
<p class='vspace'></p><h4>Tip</h4>
<p>Users who borrow code from other sources that includes double variables may wish to examine the code to see if the implied precision is different from that actually achieved on the Arduino.
</p>
<p class='vspace'></p><h4>See:</h4>
<ul><li><a class='wikilink' href='Float.html'>float</a>
</li></ul><p><a class='wikilink' href='index.html'>Reference Home</a>
</p>
<p class='vspace'></p><p><em>Corrections, suggestions, and new documentation should be posted to the <a class='urllink' href='http://arduino.cc/forum/index.php/board,23.0.html' rel='nofollow'>Forum</a>.</em>
</p>
<p class='vspace'></p><p>The text of the Arduino reference is licensed under a
<a class='urllink' href='http://creativecommons.org/licenses/by-sa/3.0/' rel='nofollow'>Creative Commons Attribution-ShareAlike 3.0 License</a>. Code samples in the reference are released into the public domain.
</p>
</div>
</div>
<!--PageFooterFmt-->
<div id="pagefooter">
&copy;Arduino |
<a href='#'>Edit Page</a> | <a href='#'>Page History</a> | <a href='#' target='_blank'>Printable View</a> | <a href='http://arduino.cc/en/Site/AllRecentChanges'>All Recent Site Changes</a>
</div>
<!--/PageFooterFmt-->
</div>
</body>
</html>

View File

@@ -0,0 +1,98 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>Arduino Reference - EEPROM </title>
<link rel="shortcut icon" type="image/x-icon" href="http://arduino.cc/en/favicon.png">
<link rel='stylesheet' href='arduinoWideRender.css'
type='text/css' />
<!--HeaderText--><style type='text/css'><!--
ul, ol, pre, dl, p { margin-top:0px; margin-bottom:0px; }
code { white-space: nowrap; }
.vspace { margin-top:1.33em; }
.indent { margin-left:40px; }
.outdent { margin-left:40px; text-indent:-40px; }
a.createlinktext { text-decoration:none; border-bottom:1px dotted gray; }
a.createlink { text-decoration:none; position:relative; top:-0.5em;
font-weight:bold; font-size:smaller; border-bottom:none; }
img { border:0px; }
.editconflict { color:green;
font-style:italic; margin-top:1.33em; margin-bottom:1.33em; }
table.markup { border: 2px dotted #ccf; width:90%; }
td.markup1, td.markup2 { padding-left:10px; padding-right:10px; }
td.markup1 { border-bottom: 1px solid #ccf; }
div.faq { margin-left:2em; }
div.faq p.question { margin: 1em 0 0.75em -2em; font-weight:bold; }
div.faq hr { margin-left: -2em; }
.frame
{ border:1px solid #cccccc; padding:4px; background-color:#f9f9f9; }
.lfloat { float:left; margin-right:0.5em; }
.rfloat { float:right; margin-left:0.5em; }
a.varlink { text-decoration:none; }
--></style> <meta name='robots' content='index,follow' />
<meta name="verify-v1" content="TtxFIEJAB6zdJ509wLxjnapQzKAMNm9u0Wj4ho6wxIY=" />
</head>
<body>
<div id="page">
<!--PageHeaderFmt-->
<div id="pageheader">
<div class="title"><a href='http://arduino.cc/en'>Arduino</a></div>
</div>
<!--/PageHeaderFmt-->
<!--PageLeftFmt-->
<div id="pagenav">
<div id="navbar">
<p><a class='wikilink' href='http://arduino.cc/en/Main/Buy'>Buy</a>
<a class='wikilink' href='http://arduino.cc/en/Main/Software'>Download</a>
<a class='wikilink' href='Guide_index.html'>Getting Started</a>
<a class='wikilink' href='http://arduino.cc/en/Tutorial/HomePage'>Learning</a>
<a class='wikilink' href='index.html'>Reference</a>
<a class='wikilink' href='http://arduino.cc/en/Main/Hardware'>Hardware</a>
<a class='wikilink' href='FAQ.html'>FAQ</a>
</p>
<p class='vspace'></p>
</div>
</div>
<!--/PageLeftFmt-->
<div id="pagetext">
<!--PageText-->
<div id='wikitext'>
<p><strong>Reference</strong> &nbsp; <a class='wikilink' href='index.html'>Language</a> | <a class='wikilink' href='Libraries.html'>Libraries</a> | <a class='wikilink' href='Comparison.html'>Comparison</a> | <a class='wikilink' href='Changes.html'>Changes</a>
</p>
<p class='vspace'></p><h2>EEPROM Library</h2>
<p>The microcontroller on the Arduino board has EEPROM: memory whose values are kept when the board is turned off (like a tiny hard drive). This library enables you to read and write those bytes.
</p>
<p class='vspace'></p><p>The microcontrollers on the various Arduino boards have different amounts of EEPROM: 1024 bytes on the <span class='wikiword'>ATmega328</span>, 512 bytes on the <span class='wikiword'>ATmega168</span> and <span class='wikiword'>ATmega8</span>, 4 KB (4096 bytes) on the <span class='wikiword'>ATmega1280</span> and <span class='wikiword'>ATmega2560</span>.
</p>
<p class='vspace'></p><h4>Functions</h4>
<ul><li><a class='wikilink' href='EEPROMRead.html'>read()</a>
</li><li><a class='wikilink' href='EEPROMWrite.html'>write()</a>
</li></ul><p><a class='wikilink' href='index.html'>Reference Home</a>
</p>
<p class='vspace'></p><p><em>Corrections, suggestions, and new documentation should be posted to the <a class='urllink' href='http://arduino.cc/forum/index.php/board,23.0.html' rel='nofollow'>Forum</a>.</em>
</p>
<p class='vspace'></p><p>The text of the Arduino reference is licensed under a
<a class='urllink' href='http://creativecommons.org/licenses/by-sa/3.0/' rel='nofollow'>Creative Commons Attribution-ShareAlike 3.0 License</a>. Code samples in the reference are released into the public domain.
</p>
</div>
</div>
<!--PageFooterFmt-->
<div id="pagefooter">
&copy;Arduino |
<a href='#'>Edit Page</a> | <a href='#'>Page History</a> | <a href='#' target='_blank'>Printable View</a> | <a href='http://arduino.cc/en/Site/AllRecentChanges'>All Recent Site Changes</a>
</div>
<!--/PageFooterFmt-->
</div>
</body>
</html>

View File

@@ -0,0 +1,137 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>Arduino Reference - EEPROMRead </title>
<link rel="shortcut icon" type="image/x-icon" href="http://arduino.cc/en/favicon.png">
<link rel='stylesheet' href='arduinoWideRender.css'
type='text/css' />
<!--HeaderText--><style type='text/css'><!--
ul, ol, pre, dl, p { margin-top:0px; margin-bottom:0px; }
code { white-space: nowrap; }
.vspace { margin-top:1.33em; }
.indent { margin-left:40px; }
.outdent { margin-left:40px; text-indent:-40px; }
a.createlinktext { text-decoration:none; border-bottom:1px dotted gray; }
a.createlink { text-decoration:none; position:relative; top:-0.5em;
font-weight:bold; font-size:smaller; border-bottom:none; }
img { border:0px; }
.editconflict { color:green;
font-style:italic; margin-top:1.33em; margin-bottom:1.33em; }
table.markup { border: 2px dotted #ccf; width:90%; }
td.markup1, td.markup2 { padding-left:10px; padding-right:10px; }
td.markup1 { border-bottom: 1px solid #ccf; }
div.faq { margin-left:2em; }
div.faq p.question { margin: 1em 0 0.75em -2em; font-weight:bold; }
div.faq hr { margin-left: -2em; }
.frame
{ border:1px solid #cccccc; padding:4px; background-color:#f9f9f9; }
.lfloat { float:left; margin-right:0.5em; }
.rfloat { float:right; margin-left:0.5em; }
a.varlink { text-decoration:none; }
--></style> <meta name='robots' content='index,follow' />
<meta name="verify-v1" content="TtxFIEJAB6zdJ509wLxjnapQzKAMNm9u0Wj4ho6wxIY=" />
</head>
<body>
<div id="page">
<!--PageHeaderFmt-->
<div id="pageheader">
<div class="title"><a href='http://arduino.cc/en'>Arduino</a></div>
</div>
<!--/PageHeaderFmt-->
<!--PageLeftFmt-->
<div id="pagenav">
<div id="navbar">
<p><a class='wikilink' href='http://arduino.cc/en/Main/Buy'>Buy</a>
<a class='wikilink' href='http://arduino.cc/en/Main/Software'>Download</a>
<a class='wikilink' href='Guide_index.html'>Getting Started</a>
<a class='wikilink' href='http://arduino.cc/en/Tutorial/HomePage'>Learning</a>
<a class='wikilink' href='index.html'>Reference</a>
<a class='wikilink' href='http://arduino.cc/en/Main/Hardware'>Hardware</a>
<a class='wikilink' href='FAQ.html'>FAQ</a>
</p>
<p class='vspace'></p>
</div>
</div>
<!--/PageLeftFmt-->
<div id="pagetext">
<!--PageText-->
<div id='wikitext'>
<p><strong>Reference</strong> &nbsp; <a class='wikilink' href='index.html'>Language</a> | <a class='wikilink' href='Libraries.html'>Libraries</a> | <a class='wikilink' href='Comparison.html'>Comparison</a> | <a class='wikilink' href='Changes.html'>Changes</a>
</p>
<p class='vspace'></p><p><a class='wikilink' href='EEPROM.html'>EEPROM</a>
</p>
<p class='vspace'></p><h2>read()</h2>
<h4>Description</h4>
<p>Reads a byte from the EEPROM. Locations that have never been written to have the value of 255.
</p>
<p class='vspace'></p><h4>Syntax</h4>
<p>EEPROM.read(address)
</p>
<p class='vspace'></p><h4>Parameters</h4>
<p>address: the location to read from, starting from 0 (<em>int</em>)
</p>
<p class='vspace'></p><h4>Returns</h4>
<p>the value stored in that location (<em>byte</em>)
</p>
<p class='vspace'></p><h4>Example</h4>
<pre>
#include &lt;EEPROM.h&gt;
int a = 0;
int value;
void setup()
{
Serial.begin(9600);
}
void loop()
{
value = EEPROM.read(a);
Serial.print(a);
Serial.print("\t");
Serial.print(value);
Serial.println();
a = a + 1;
if (a == 512)
a = 0;
delay(500);
}
</pre>
<p class='vspace'></p><h4>See also</h4>
<ul><li><a class='wikilink' href='EEPROMWrite.html'>write</a>()
</li></ul><p><a class='wikilink' href='index.html'>Reference Home</a>
</p>
<p class='vspace'></p><p><em>Corrections, suggestions, and new documentation should be posted to the <a class='urllink' href='http://arduino.cc/forum/index.php/board,23.0.html' rel='nofollow'>Forum</a>.</em>
</p>
<p class='vspace'></p><p>The text of the Arduino reference is licensed under a
<a class='urllink' href='http://creativecommons.org/licenses/by-sa/3.0/' rel='nofollow'>Creative Commons Attribution-ShareAlike 3.0 License</a>. Code samples in the reference are released into the public domain.
</p>
</div>
</div>
<!--PageFooterFmt-->
<div id="pagefooter">
&copy;Arduino |
<a href='#'>Edit Page</a> | <a href='#'>Page History</a> | <a href='#' target='_blank'>Printable View</a> | <a href='http://arduino.cc/en/Site/AllRecentChanges'>All Recent Site Changes</a>
</div>
<!--/PageFooterFmt-->
</div>
</body>
</html>

View File

@@ -0,0 +1,185 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>Arduino Reference - EEPROMWrite </title>
<link rel="shortcut icon" type="image/x-icon" href="http://arduino.cc/en/favicon.png">
<link rel='stylesheet' href='arduinoWideRender.css'
type='text/css' />
<!--HeaderText--><style type='text/css'><!--
ul, ol, pre, dl, p { margin-top:0px; margin-bottom:0px; }
code { white-space: nowrap; }
.vspace { margin-top:1.33em; }
.indent { margin-left:40px; }
.outdent { margin-left:40px; text-indent:-40px; }
a.createlinktext { text-decoration:none; border-bottom:1px dotted gray; }
a.createlink { text-decoration:none; position:relative; top:-0.5em;
font-weight:bold; font-size:smaller; border-bottom:none; }
img { border:0px; }
.editconflict { color:green;
font-style:italic; margin-top:1.33em; margin-bottom:1.33em; }
table.markup { border: 2px dotted #ccf; width:90%; }
td.markup1, td.markup2 { padding-left:10px; padding-right:10px; }
td.markup1 { border-bottom: 1px solid #ccf; }
div.faq { margin-left:2em; }
div.faq p.question { margin: 1em 0 0.75em -2em; font-weight:bold; }
div.faq hr { margin-left: -2em; }
.frame
{ border:1px solid #cccccc; padding:4px; background-color:#f9f9f9; }
.lfloat { float:left; margin-right:0.5em; }
.rfloat { float:right; margin-left:0.5em; }
a.varlink { text-decoration:none; }
/**
* GeSHi (C) 2004 - 2007 Nigel McNie, 2007 - 2008 Benny Baumann
* (http://qbnz.com/highlighter/ and http://geshi.org/)
*/
.arduino {font-family:monospace;}
.arduino .imp {font-weight: bold; color: red;}
.arduino .kw1 {color: #CC6600;}
.arduino .kw2 {color: #006699;}
.arduino .kw3 {color: #CC6600; font-weight: bold;}
.arduino .co1 {color: #7E7E7E; font-style: italic;}
.arduino .co2 {color: #7E7E7E;}
.arduino .coMULTI {color: #7E7E7E; font-style: italic;}
.arduino .es0 {color: #000099; font-weight: bold;}
.arduino .es1 {color: #000099; font-weight: bold;}
.arduino .es2 {color: #660099; font-weight: bold;}
.arduino .es3 {color: #660099; font-weight: bold;}
.arduino .es4 {color: #660099; font-weight: bold;}
.arduino .es5 {color: #006699; font-weight: bold;}
.arduino .br0 {color: #000000;}
.arduino .sy0 {color: #000000;}
.arduino .st0 {color: #0066CC;}
.arduino .nu0 {color: #000000;}
.arduino .nu6 {color: #208080;}
.arduino .nu8 {color: #208080;}
.arduino .nu12 {color: #208080;}
.arduino .nu16 {color:#800080;}
.arduino .nu17 {color:#800080;}
.arduino .nu18 {color:#800080;}
.arduino .nu19 {color:#800080;}
.arduino .me1 {color: #ff1493;}
.arduino .me2 {color: #ff1493;}
.arduino span.xtra { display:block; }
.sourceblocklink {
text-align: right;
font-size: smaller;
}
.sourceblocktext {
padding: 0.5em;
color: #000000;
background-color: #ffffff;
}
.sourceblocktext div {
font-family: monospace;
font-size: small;
line-height: 1;
height: 1%;
}
.sourceblocktext div.head,
.sourceblocktext div.foot {
font: italic medium serif;
padding: 0.5em;
}
--></style> <meta name='robots' content='index,follow' />
<meta name="verify-v1" content="TtxFIEJAB6zdJ509wLxjnapQzKAMNm9u0Wj4ho6wxIY=" />
</head>
<body>
<div id="page">
<!--PageHeaderFmt-->
<div id="pageheader">
<div class="title"><a href='http://arduino.cc/en'>Arduino</a></div>
</div>
<!--/PageHeaderFmt-->
<!--PageLeftFmt-->
<div id="pagenav">
<div id="navbar">
<p><a class='wikilink' href='http://arduino.cc/en/Main/Buy'>Buy</a>
<a class='wikilink' href='http://arduino.cc/en/Main/Software'>Download</a>
<a class='wikilink' href='Guide_index.html'>Getting Started</a>
<a class='wikilink' href='http://arduino.cc/en/Tutorial/HomePage'>Learning</a>
<a class='wikilink' href='index.html'>Reference</a>
<a class='wikilink' href='http://arduino.cc/en/Main/Hardware'>Hardware</a>
<a class='wikilink' href='FAQ.html'>FAQ</a>
</p>
<p class='vspace'></p>
</div>
</div>
<!--/PageLeftFmt-->
<div id="pagetext">
<!--PageText-->
<div id='wikitext'>
<p><strong>Reference</strong> &nbsp; <a class='wikilink' href='index.html'>Language</a> | <a class='wikilink' href='Libraries.html'>Libraries</a> | <a class='wikilink' href='Comparison.html'>Comparison</a> | <a class='wikilink' href='Changes.html'>Changes</a>
</p>
<p class='vspace'></p><p><a class='wikilink' href='EEPROM.html'>EEPROM</a>
</p>
<p class='vspace'></p><h2>write()</h2>
<h4>Description</h4>
<p>Write a byte to the EEPROM.
</p>
<p class='vspace'></p><h4>Syntax</h4>
<p>EEPROM.write(address, value)
</p>
<p class='vspace'></p><h4>Parameters</h4>
<p>address: the location to write to, starting from 0 (<em>int</em>)
</p>
<p class='vspace'></p><p>value: the value to write, from 0 to 255 (<em>byte</em>)
</p>
<p class='vspace'></p><h4>Returns</h4>
<p>none
</p>
<p class='vspace'></p><h4>Note</h4>
<p>An EEPROM write takes 3.3 ms to complete. The EEPROM memory has a specified life of 100,000 write/erase cycles, so you may need to be careful about how often you write to it.
</p>
<p class='vspace'></p><h4>Example</h4>
<p>
<div class='sourceblock ' id='sourceblock1'>
<div class='sourceblocktext'><div class="arduino"><br />
<span class="co2">#include &lt;EEPROM.h&gt;</span><br />
<br />
<span class="kw1">void</span> <span class="kw3">setup</span><span class="br0">&#40;</span><span class="br0">&#41;</span><br />
<span class="br0">&#123;</span><br />
&nbsp; <span class="kw1">for</span> <span class="br0">&#40;</span><span class="kw1">int</span> i <span class="sy0">=</span> <span class="nu0">0</span><span class="sy0">;</span> i <span class="sy0">&lt;</span> <span class="nu0">512</span><span class="sy0">;</span> i<span class="sy0">++</span><span class="br0">&#41;</span><br />
&nbsp; &nbsp; EEPROM.<span class="kw1">write</span><span class="br0">&#40;</span>i<span class="sy0">,</span> i<span class="br0">&#41;</span><span class="sy0">;</span><br />
<span class="br0">&#125;</span><br />
<br />
<span class="kw1">void</span> <span class="kw3">loop</span><span class="br0">&#40;</span><span class="br0">&#41;</span><br />
<span class="br0">&#123;</span><br />
<span class="br0">&#125;</span><br />
&nbsp;</div></div>
<div class='sourceblocklink'><a href='#' type='text/plain'>[Get Code]</a></div>
</div>
</p>
<p class='vspace'></p><h4>See also</h4>
<ul><li><a class='wikilink' href='EEPROMRead.html'>EEPROM.read</a>()
</li></ul><p><a class='wikilink' href='index.html'>Reference Home</a>
</p>
<p class='vspace'></p><p><em>Corrections, suggestions, and new documentation should be posted to the <a class='urllink' href='http://arduino.cc/forum/index.php/board,23.0.html' rel='nofollow'>Forum</a>.</em>
</p>
<p class='vspace'></p><p>The text of the Arduino reference is licensed under a
<a class='urllink' href='http://creativecommons.org/licenses/by-sa/3.0/' rel='nofollow'>Creative Commons Attribution-ShareAlike 3.0 License</a>. Code samples in the reference are released into the public domain.
</p>
</div>
</div>
<!--PageFooterFmt-->
<div id="pagefooter">
&copy;Arduino |
<a href='#'>Edit Page</a> | <a href='#'>Page History</a> | <a href='#' target='_blank'>Printable View</a> | <a href='http://arduino.cc/en/Site/AllRecentChanges'>All Recent Site Changes</a>
</div>
<!--/PageFooterFmt-->
</div>
</body>
</html>

View File

@@ -0,0 +1,125 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>Arduino Reference - Else </title>
<link rel="shortcut icon" type="image/x-icon" href="http://arduino.cc/en/favicon.png">
<link rel='stylesheet' href='arduinoWideRender.css'
type='text/css' />
<!--HeaderText--><style type='text/css'><!--
ul, ol, pre, dl, p { margin-top:0px; margin-bottom:0px; }
code { white-space: nowrap; }
.vspace { margin-top:1.33em; }
.indent { margin-left:40px; }
.outdent { margin-left:40px; text-indent:-40px; }
a.createlinktext { text-decoration:none; border-bottom:1px dotted gray; }
a.createlink { text-decoration:none; position:relative; top:-0.5em;
font-weight:bold; font-size:smaller; border-bottom:none; }
img { border:0px; }
.editconflict { color:green;
font-style:italic; margin-top:1.33em; margin-bottom:1.33em; }
table.markup { border: 2px dotted #ccf; width:90%; }
td.markup1, td.markup2 { padding-left:10px; padding-right:10px; }
td.markup1 { border-bottom: 1px solid #ccf; }
div.faq { margin-left:2em; }
div.faq p.question { margin: 1em 0 0.75em -2em; font-weight:bold; }
div.faq hr { margin-left: -2em; }
.frame
{ border:1px solid #cccccc; padding:4px; background-color:#f9f9f9; }
.lfloat { float:left; margin-right:0.5em; }
.rfloat { float:right; margin-left:0.5em; }
a.varlink { text-decoration:none; }
--></style> <meta name='robots' content='index,follow' />
<meta name="verify-v1" content="TtxFIEJAB6zdJ509wLxjnapQzKAMNm9u0Wj4ho6wxIY=" />
</head>
<body>
<div id="page">
<!--PageHeaderFmt-->
<div id="pageheader">
<div class="title"><a href='http://arduino.cc/en'>Arduino</a></div>
</div>
<!--/PageHeaderFmt-->
<!--PageLeftFmt-->
<div id="pagenav">
<div id="navbar">
<p><a class='wikilink' href='http://arduino.cc/en/Main/Buy'>Buy</a>
<a class='wikilink' href='http://arduino.cc/en/Main/Software'>Download</a>
<a class='wikilink' href='Guide_index.html'>Getting Started</a>
<a class='wikilink' href='http://arduino.cc/en/Tutorial/HomePage'>Learning</a>
<a class='wikilink' href='index.html'>Reference</a>
<a class='wikilink' href='http://arduino.cc/en/Main/Hardware'>Hardware</a>
<a class='wikilink' href='FAQ.html'>FAQ</a>
</p>
<p class='vspace'></p>
</div>
</div>
<!--/PageLeftFmt-->
<div id="pagetext">
<!--PageText-->
<div id='wikitext'>
<p><strong>Reference</strong> &nbsp; <a class='wikilink' href='index.html'>Language</a> | <a class='wikilink' href='Libraries.html'>Libraries</a> | <a class='wikilink' href='Comparison.html'>Comparison</a> | <a class='wikilink' href='Changes.html'>Changes</a>
</p>
<p class='vspace'></p><h2>if / else</h2>
<p><strong>if/else</strong> allows greater control over the flow of code than the basic <strong>if</strong> statement, by allowing multiple tests to be grouped together. For example, an analog input could be tested and one action taken if the input was less than 500, and another action taken if the input was 500 or greater. The code would look like this:
</p>
<p class='vspace'></p><pre>if (pinFiveInput &lt; 500)
{
// action A
}
else
{
// action B
}
</pre>
<p class='vspace'></p><p><strong>else</strong> can proceed another <strong>if</strong> test, so that multiple, mutually exclusive tests can be run at the same time.
</p>
<p class='vspace'></p><p>Each test will proceed to the next one until a true test is encountered. When a true test is found, its associated block of code is run, and the program then skips to the line following the entire if/else construction. If no test proves to be true, the default <strong>else</strong> block is executed, if one is present, and sets the default behavior.
</p>
<p class='vspace'></p><p>Note that an <strong>else if</strong> block may be used with or without a terminating <strong>else</strong> block and vice versa. An unlimited number of such <strong>else if</strong> branches is allowed.
</p>
<p class='vspace'></p><pre>if (pinFiveInput &lt; 500)
{
// do Thing A
}
else if (pinFiveInput &gt;= 1000)
{
// do Thing B
}
else
{
// do Thing C
}
</pre><p>Another way to express branching, mutually exclusive tests, is with the <a class='wikilink' href='SwitchCase.html'>switch case</a> statement.
</p>
<p class='vspace'></p><h4>See also:</h4>
<p><a class='wikilink' href='SwitchCase.html'>switch case</a>
<a class='wikilink' href='index.html'>Reference Home</a>
</p>
<p class='vspace'></p><p><em>Corrections, suggestions, and new documentation should be posted to the <a class='urllink' href='http://arduino.cc/forum/index.php/board,23.0.html' rel='nofollow'>Forum</a>.</em>
</p>
<p class='vspace'></p><p>The text of the Arduino reference is licensed under a
<a class='urllink' href='http://creativecommons.org/licenses/by-sa/3.0/' rel='nofollow'>Creative Commons Attribution-ShareAlike 3.0 License</a>. Code samples in the reference are released into the public domain.
</p>
</div>
</div>
<!--PageFooterFmt-->
<div id="pagefooter">
&copy;Arduino |
<a href='#'>Edit Page</a> | <a href='#'>Page History</a> | <a href='#' target='_blank'>Printable View</a> | <a href='http://arduino.cc/en/Site/AllRecentChanges'>All Recent Site Changes</a>
</div>
<!--/PageFooterFmt-->
</div>
</body>
</html>

View File

@@ -0,0 +1,142 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>Arduino Reference - Ethernet </title>
<link rel="shortcut icon" type="image/x-icon" href="http://arduino.cc/en/favicon.png">
<link rel='stylesheet' href='arduinoWideRender.css'
type='text/css' />
<!--HeaderText--><style type='text/css'><!--
ul, ol, pre, dl, p { margin-top:0px; margin-bottom:0px; }
code { white-space: nowrap; }
.vspace { margin-top:1.33em; }
.indent { margin-left:40px; }
.outdent { margin-left:40px; text-indent:-40px; }
a.createlinktext { text-decoration:none; border-bottom:1px dotted gray; }
a.createlink { text-decoration:none; position:relative; top:-0.5em;
font-weight:bold; font-size:smaller; border-bottom:none; }
img { border:0px; }
.editconflict { color:green;
font-style:italic; margin-top:1.33em; margin-bottom:1.33em; }
table.markup { border: 2px dotted #ccf; width:90%; }
td.markup1, td.markup2 { padding-left:10px; padding-right:10px; }
td.markup1 { border-bottom: 1px solid #ccf; }
div.faq { margin-left:2em; }
div.faq p.question { margin: 1em 0 0.75em -2em; font-weight:bold; }
div.faq hr { margin-left: -2em; }
.frame
{ border:1px solid #cccccc; padding:4px; background-color:#f9f9f9; }
.lfloat { float:left; margin-right:0.5em; }
.rfloat { float:right; margin-left:0.5em; }
a.varlink { text-decoration:none; }
--></style> <meta name='robots' content='index,follow' />
<meta name="verify-v1" content="TtxFIEJAB6zdJ509wLxjnapQzKAMNm9u0Wj4ho6wxIY=" />
</head>
<body>
<div id="page">
<!--PageHeaderFmt-->
<div id="pageheader">
<div class="title"><a href='http://arduino.cc/en'>Arduino</a></div>
</div>
<!--/PageHeaderFmt-->
<!--PageLeftFmt-->
<div id="pagenav">
<div id="navbar">
<p><a class='wikilink' href='http://arduino.cc/en/Main/Buy'>Buy</a>
<a class='wikilink' href='http://arduino.cc/en/Main/Software'>Download</a>
<a class='wikilink' href='Guide_index.html'>Getting Started</a>
<a class='wikilink' href='http://arduino.cc/en/Tutorial/HomePage'>Learning</a>
<a class='wikilink' href='index.html'>Reference</a>
<a class='wikilink' href='http://arduino.cc/en/Main/Hardware'>Hardware</a>
<a class='wikilink' href='FAQ.html'>FAQ</a>
</p>
<p class='vspace'></p>
</div>
</div>
<!--/PageLeftFmt-->
<div id="pagetext">
<!--PageText-->
<div id='wikitext'>
<p><strong>Reference</strong> &nbsp; <a class='wikilink' href='index.html'>Language</a> | <a class='wikilink' href='Libraries.html'>Libraries</a> | <a class='wikilink' href='Comparison.html'>Comparison</a> | <a class='wikilink' href='Changes.html'>Changes</a>
</p>
<p class='vspace'></p><h2>Ethernet library</h2>
<p>With the Arduino Ethernet Shield, this library allows an Arduino board to connect to the internet. It can serve as either a server accepting incoming connections or a client making outgoing ones. The library supports up to four concurrent connection (incoming or outgoing or a combination).
</p>
<p class='vspace'></p><p>Arduino communicates with the shield using the SPI bus. This is on digital pins 11, 12, and 13 on the Uno and pins 50, 51, and 52 on the Mega. <strong>On both boards, pin 10 is used as SS.</strong> On the Mega, the hardware SS pin, 53, is not used to select the W5100, but it must be kept as an output or the SPI interface won't work.
</p>
<p class='vspace'></p><div><img src='http://arduino.cc/en/uploads/Reference/arduino_uno_ethernet_pins.png' alt='' title='' /></div>
<p class='vspace'></p><div><img src='http://arduino.cc/en/uploads/Reference/arduino_mega_ethernet_pins.png' alt='' title='' /></div>
<p class='vspace'></p><h4>Ethernet class</h4>
<p>The Ethernet class initializes the ethernet library and network settings.
</p>
<p class='vspace'></p><ul><li><a class='wikilink' href='EthernetBegin.html'>begin()</a>
</li><li><a class='wikilink' href='EthernetLocalIP.html'>localIP()</a>
</li></ul><p class='vspace'></p><h4><span class='wikiword'>IPAddress</span> class</h4>
<p>The <span class='wikiword'>IPAddress</span> class works with local and remote IP addressing.
</p>
<p class='vspace'></p><ul><li><a class='wikilink' href='EthernetIPAddress.html'>IPAddress()</a>
</li></ul><p class='vspace'></p><h4>Server class</h4>
<p>The Server class creates servers which can send data to and receive data from connected clients (programs running on other computers or devices).
</p>
<p class='vspace'></p><ul><li><a class='wikilink' href='ServerConstructor.html'>Server</a>
<p class='vspace'></p></li><li><a class='wikilink' href='EthernetServer.html'>EthernetServer()</a>
</li><li><a class='wikilink' href='ServerBegin.html'>begin()</a>
</li><li><a class='wikilink' href='ServerAvailable.html'>available()</a>
</li><li><a class='wikilink' href='ServerWrite.html'>write()</a>
</li><li><a class='wikilink' href='ServerPrint.html'>print()</a>
</li><li><a class='wikilink' href='ServerPrintln.html'>println()</a>
</li></ul><p class='vspace'></p><h4>Client class</h4>
<p>The client class creates clients that can connect to servers and send and receive data.
</p>
<p class='vspace'></p><ul><li><a class='wikilink' href='ClientConstructor.html'>Client</a>
<p class='vspace'></p></li><li><a class='wikilink' href='EthernetClient.html'>EthernetClient()</a>
</li><li><a class='wikilink' href='ClientConnected.html'>connected()</a>
</li><li><a class='wikilink' href='ClientConnect.html'>connect()</a>
</li><li><a class='wikilink' href='ClientWrite.html'>write()</a>
</li><li><a class='wikilink' href='ClientPrint.html'>print()</a>
</li><li><a class='wikilink' href='ClientPrintln.html'>println()</a>
</li><li><a class='wikilink' href='ClientAvailable.html'>available()</a>
</li><li><a class='wikilink' href='ClientRead.html'>read()</a>
</li><li><a class='wikilink' href='ClientFlush.html'>flush()</a>
</li><li><a class='wikilink' href='ClientStop.html'>stop()</a>
</li></ul><p class='vspace'></p><h4><span class='wikiword'>EthernetUDP</span> class</h4>
<p>The <span class='wikiword'>EthernetUDP</span> class enables UDP message to be sent and received.
</p>
<p class='vspace'></p><ul><li><a class='wikilink' href='EthernetUDPBegin.html'>begin()</a>
</li><li><a class='wikilink' href='EthernetUDPRead.html'>read()</a>
</li><li><a class='wikilink' href='EthernetUDPWrite.html'>write()</a>
</li><li><a class='wikilink' href='EthernetUDPBeginPacket.html'>beginPacket()</a>
</li><li><a class='wikilink' href='EthernetUDPEndPacket.html'>endPacket()</a>
</li><li><a class='wikilink' href='EthernetUDPParsePacket.html'>parsePacket()</a>
</li><li><a class='wikilink' href='EthernetUDPAvailable.html'>available()</a>
</li><li><a class='wikilink' href='EthernetUDPRemoteIP.html'>remoteIP()</a>
</li><li><a class='wikilink' href='EthernetUDPRemotePort.html'>remotePort()</a>
</li></ul><p><a class='wikilink' href='index.html'>Reference Home</a>
</p>
<p class='vspace'></p><p><em>Corrections, suggestions, and new documentation should be posted to the <a class='urllink' href='http://arduino.cc/forum/index.php/board,23.0.html' rel='nofollow'>Forum</a>.</em>
</p>
<p class='vspace'></p><p>The text of the Arduino reference is licensed under a
<a class='urllink' href='http://creativecommons.org/licenses/by-sa/3.0/' rel='nofollow'>Creative Commons Attribution-ShareAlike 3.0 License</a>. Code samples in the reference are released into the public domain.
</p>
</div>
</div>
<!--PageFooterFmt-->
<div id="pagefooter">
&copy;Arduino |
<a href='#'>Edit Page</a> | <a href='#'>Page History</a> | <a href='#' target='_blank'>Printable View</a> | <a href='http://arduino.cc/en/Site/AllRecentChanges'>All Recent Site Changes</a>
</div>
<!--/PageFooterFmt-->
</div>
</body>
</html>

View File

@@ -0,0 +1,185 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>Arduino Reference - EthernetBegin </title>
<link rel="shortcut icon" type="image/x-icon" href="http://arduino.cc/en/favicon.png">
<link rel='stylesheet' href='arduinoWideRender.css'
type='text/css' />
<!--HeaderText--><style type='text/css'><!--
ul, ol, pre, dl, p { margin-top:0px; margin-bottom:0px; }
code { white-space: nowrap; }
.vspace { margin-top:1.33em; }
.indent { margin-left:40px; }
.outdent { margin-left:40px; text-indent:-40px; }
a.createlinktext { text-decoration:none; border-bottom:1px dotted gray; }
a.createlink { text-decoration:none; position:relative; top:-0.5em;
font-weight:bold; font-size:smaller; border-bottom:none; }
img { border:0px; }
.editconflict { color:green;
font-style:italic; margin-top:1.33em; margin-bottom:1.33em; }
table.markup { border: 2px dotted #ccf; width:90%; }
td.markup1, td.markup2 { padding-left:10px; padding-right:10px; }
td.markup1 { border-bottom: 1px solid #ccf; }
div.faq { margin-left:2em; }
div.faq p.question { margin: 1em 0 0.75em -2em; font-weight:bold; }
div.faq hr { margin-left: -2em; }
.frame
{ border:1px solid #cccccc; padding:4px; background-color:#f9f9f9; }
.lfloat { float:left; margin-right:0.5em; }
.rfloat { float:right; margin-left:0.5em; }
a.varlink { text-decoration:none; }
/**
* GeSHi (C) 2004 - 2007 Nigel McNie, 2007 - 2008 Benny Baumann
* (http://qbnz.com/highlighter/ and http://geshi.org/)
*/
.arduino {font-family:monospace;}
.arduino .imp {font-weight: bold; color: red;}
.arduino .kw1 {color: #CC6600;}
.arduino .kw2 {color: #006699;}
.arduino .kw3 {color: #CC6600; font-weight: bold;}
.arduino .co1 {color: #7E7E7E; font-style: italic;}
.arduino .co2 {color: #7E7E7E;}
.arduino .coMULTI {color: #7E7E7E; font-style: italic;}
.arduino .es0 {color: #000099; font-weight: bold;}
.arduino .es1 {color: #000099; font-weight: bold;}
.arduino .es2 {color: #660099; font-weight: bold;}
.arduino .es3 {color: #660099; font-weight: bold;}
.arduino .es4 {color: #660099; font-weight: bold;}
.arduino .es5 {color: #006699; font-weight: bold;}
.arduino .br0 {color: #000000;}
.arduino .sy0 {color: #000000;}
.arduino .st0 {color: #0066CC;}
.arduino .nu0 {color: #000000;}
.arduino .nu6 {color: #208080;}
.arduino .nu8 {color: #208080;}
.arduino .nu12 {color: #208080;}
.arduino .nu16 {color:#800080;}
.arduino .nu17 {color:#800080;}
.arduino .nu18 {color:#800080;}
.arduino .nu19 {color:#800080;}
.arduino .me1 {color: #ff1493;}
.arduino .me2 {color: #ff1493;}
.arduino span.xtra { display:block; }
.sourceblocklink {
text-align: right;
font-size: smaller;
}
.sourceblocktext {
padding: 0.5em;
color: #000000;
background-color: #ffffff;
}
.sourceblocktext div {
font-family: monospace;
font-size: small;
line-height: 1;
height: 1%;
}
.sourceblocktext div.head,
.sourceblocktext div.foot {
font: italic medium serif;
padding: 0.5em;
}
--></style> <meta name='robots' content='index,follow' />
<meta name="verify-v1" content="TtxFIEJAB6zdJ509wLxjnapQzKAMNm9u0Wj4ho6wxIY=" />
</head>
<body>
<div id="page">
<!--PageHeaderFmt-->
<div id="pageheader">
<div class="title"><a href='http://arduino.cc/en'>Arduino</a></div>
</div>
<!--/PageHeaderFmt-->
<!--PageLeftFmt-->
<div id="pagenav">
<div id="navbar">
<p><a class='wikilink' href='http://arduino.cc/en/Main/Buy'>Buy</a>
<a class='wikilink' href='http://arduino.cc/en/Main/Software'>Download</a>
<a class='wikilink' href='Guide_index.html'>Getting Started</a>
<a class='wikilink' href='http://arduino.cc/en/Tutorial/HomePage'>Learning</a>
<a class='wikilink' href='index.html'>Reference</a>
<a class='wikilink' href='http://arduino.cc/en/Main/Hardware'>Hardware</a>
<a class='wikilink' href='FAQ.html'>FAQ</a>
</p>
<p class='vspace'></p>
</div>
</div>
<!--/PageLeftFmt-->
<div id="pagetext">
<!--PageText-->
<div id='wikitext'>
<p><strong>Reference</strong> &nbsp; <a class='wikilink' href='index.html'>Language</a> | <a class='wikilink' href='Libraries.html'>Libraries</a> | <a class='wikilink' href='Comparison.html'>Comparison</a> | <a class='wikilink' href='Changes.html'>Changes</a>
</p>
<p class='vspace'></p><p><a class='wikilink' href='Ethernet.html'>Ethernet</a>
</p>
<p class='vspace'></p><h2>Ethernet.begin()</h2>
<h4>Description</h4>
<p>Initializes the ethernet library and network settings.
</p>
<p class='vspace'></p><p>With version 1.0, the library supports DHCP. Using Ethernet.begin(mac) with the proper network setup, the Ethernet shield will automatically obtain an IP address. This increases the sketch size significantly.
</p>
<p class='vspace'></p><h4>Syntax</h4>
<p>Ethernet.begin(mac); <br />Ethernet.begin(mac, ip); <br />Ethernet.begin(mac, ip, gateway); <br />Ethernet.begin(mac, ip, gateway, subnet); <br />
</p><h4>Parameters</h4>
<p><strong>mac</strong>: the MAC (Media access control) address for the device (array of 6 bytes). this is the Ethernet hardware address of your shield. Newer Arduino Ethernet Shields include a sticker with the device's MAC address. For older shields, choose your own.
</p>
<p class='vspace'></p><p><strong>ip</strong>: the IP address of the device (array of 4 bytes)
</p>
<p class='vspace'></p><p><strong>gateway</strong>: the IP address of the network gateway (array of 4 bytes). optional: defaults to the device IP address with the last octet set to 1
</p>
<p class='vspace'></p><p><strong>subnet</strong>: the subnet mask of the network (array of 4 bytes). optional: defaults to 255.255.255.0
</p>
<p class='vspace'></p><h4>Returns</h4>
<p>None
</p>
<p class='vspace'></p><h4>Example</h4>
<p>
<div class='sourceblock ' id='sourceblock1'>
<div class='sourceblocktext'><div class="arduino"><span class="co2">#include &lt;Ethernet.h&gt;</span><br />
<br />
<span class="co1">// the media access control (ethernet hardware) address for the shield:</span><br />
<span class="kw1">byte</span> mac<span class="br0">&#91;</span><span class="br0">&#93;</span> <span class="sy0">=</span> <span class="br0">&#123;</span> <span class="nu12">0xDE</span><span class="sy0">,</span> <span class="nu12">0xAD</span><span class="sy0">,</span> <span class="nu12">0xBE</span><span class="sy0">,</span> <span class="nu12">0xEF</span><span class="sy0">,</span> <span class="nu12">0xFE</span><span class="sy0">,</span> <span class="nu12">0xED</span> <span class="br0">&#125;</span><span class="sy0">;</span> &nbsp;<br />
<span class="co1">//the IP address for the shield:</span><br />
<span class="kw1">byte</span> ip<span class="br0">&#91;</span><span class="br0">&#93;</span> <span class="sy0">=</span> <span class="br0">&#123;</span> <span class="nu0">10</span><span class="sy0">,</span> <span class="nu0">0</span><span class="sy0">,</span> <span class="nu0">0</span><span class="sy0">,</span> <span class="nu0">177</span> <span class="br0">&#125;</span><span class="sy0">;</span> &nbsp; &nbsp;<br />
<br />
<span class="kw1">void</span> <span class="kw3">setup</span><span class="br0">&#40;</span><span class="br0">&#41;</span><br />
<span class="br0">&#123;</span><br />
&nbsp; Ethernet.<span class="kw1">begin</span><span class="br0">&#40;</span>mac<span class="sy0">,</span> ip<span class="br0">&#41;</span><span class="sy0">;</span><br />
<span class="br0">&#125;</span><br />
<br />
<span class="kw1">void</span> <span class="kw3">loop</span> <span class="br0">&#40;</span><span class="br0">&#41;</span> <span class="br0">&#123;</span><span class="br0">&#125;</span></div></div>
<div class='sourceblocklink'><a href='#' type='text/plain'>[Get Code]</a></div>
</div>
</p>
<p class='vspace'></p><p><a class='wikilink' href='index.html'>Reference Home</a>
</p>
<p class='vspace'></p><p><em>Corrections, suggestions, and new documentation should be posted to the <a class='urllink' href='http://arduino.cc/forum/index.php/board,23.0.html' rel='nofollow'>Forum</a>.</em>
</p>
<p class='vspace'></p><p>The text of the Arduino reference is licensed under a
<a class='urllink' href='http://creativecommons.org/licenses/by-sa/3.0/' rel='nofollow'>Creative Commons Attribution-ShareAlike 3.0 License</a>. Code samples in the reference are released into the public domain.
</p>
</div>
</div>
<!--PageFooterFmt-->
<div id="pagefooter">
&copy;Arduino |
<a href='#'>Edit Page</a> | <a href='#'>Page History</a> | <a href='#' target='_blank'>Printable View</a> | <a href='http://arduino.cc/en/Site/AllRecentChanges'>All Recent Site Changes</a>
</div>
<!--/PageFooterFmt-->
</div>
</body>
</html>

View File

@@ -0,0 +1,204 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>Arduino Reference - EthernetClient </title>
<link rel="shortcut icon" type="image/x-icon" href="http://arduino.cc/en/favicon.png">
<link rel='stylesheet' href='arduinoWideRender.css'
type='text/css' />
<!--HeaderText--><style type='text/css'><!--
ul, ol, pre, dl, p { margin-top:0px; margin-bottom:0px; }
code { white-space: nowrap; }
.vspace { margin-top:1.33em; }
.indent { margin-left:40px; }
.outdent { margin-left:40px; text-indent:-40px; }
a.createlinktext { text-decoration:none; border-bottom:1px dotted gray; }
a.createlink { text-decoration:none; position:relative; top:-0.5em;
font-weight:bold; font-size:smaller; border-bottom:none; }
img { border:0px; }
.editconflict { color:green;
font-style:italic; margin-top:1.33em; margin-bottom:1.33em; }
table.markup { border: 2px dotted #ccf; width:90%; }
td.markup1, td.markup2 { padding-left:10px; padding-right:10px; }
td.markup1 { border-bottom: 1px solid #ccf; }
div.faq { margin-left:2em; }
div.faq p.question { margin: 1em 0 0.75em -2em; font-weight:bold; }
div.faq hr { margin-left: -2em; }
.frame
{ border:1px solid #cccccc; padding:4px; background-color:#f9f9f9; }
.lfloat { float:left; margin-right:0.5em; }
.rfloat { float:right; margin-left:0.5em; }
a.varlink { text-decoration:none; }
/**
* GeSHi (C) 2004 - 2007 Nigel McNie, 2007 - 2008 Benny Baumann
* (http://qbnz.com/highlighter/ and http://geshi.org/)
*/
.arduino {font-family:monospace;}
.arduino .imp {font-weight: bold; color: red;}
.arduino .kw1 {color: #CC6600;}
.arduino .kw2 {color: #006699;}
.arduino .kw3 {color: #CC6600; font-weight: bold;}
.arduino .co1 {color: #7E7E7E; font-style: italic;}
.arduino .co2 {color: #7E7E7E;}
.arduino .coMULTI {color: #7E7E7E; font-style: italic;}
.arduino .es0 {color: #000099; font-weight: bold;}
.arduino .es1 {color: #000099; font-weight: bold;}
.arduino .es2 {color: #660099; font-weight: bold;}
.arduino .es3 {color: #660099; font-weight: bold;}
.arduino .es4 {color: #660099; font-weight: bold;}
.arduino .es5 {color: #006699; font-weight: bold;}
.arduino .br0 {color: #000000;}
.arduino .sy0 {color: #000000;}
.arduino .st0 {color: #0066CC;}
.arduino .nu0 {color: #000000;}
.arduino .nu6 {color: #208080;}
.arduino .nu8 {color: #208080;}
.arduino .nu12 {color: #208080;}
.arduino .nu16 {color:#800080;}
.arduino .nu17 {color:#800080;}
.arduino .nu18 {color:#800080;}
.arduino .nu19 {color:#800080;}
.arduino .me1 {color: #ff1493;}
.arduino .me2 {color: #ff1493;}
.arduino span.xtra { display:block; }
.sourceblocklink {
text-align: right;
font-size: smaller;
}
.sourceblocktext {
padding: 0.5em;
color: #000000;
background-color: #ffffff;
}
.sourceblocktext div {
font-family: monospace;
font-size: small;
line-height: 1;
height: 1%;
}
.sourceblocktext div.head,
.sourceblocktext div.foot {
font: italic medium serif;
padding: 0.5em;
}
--></style> <meta name='robots' content='index,follow' />
<meta name="verify-v1" content="TtxFIEJAB6zdJ509wLxjnapQzKAMNm9u0Wj4ho6wxIY=" />
</head>
<body>
<div id="page">
<!--PageHeaderFmt-->
<div id="pageheader">
<div class="title"><a href='http://arduino.cc/en'>Arduino</a></div>
</div>
<!--/PageHeaderFmt-->
<!--PageLeftFmt-->
<div id="pagenav">
<div id="navbar">
<p><a class='wikilink' href='http://arduino.cc/en/Main/Buy'>Buy</a>
<a class='wikilink' href='http://arduino.cc/en/Main/Software'>Download</a>
<a class='wikilink' href='Guide_index.html'>Getting Started</a>
<a class='wikilink' href='http://arduino.cc/en/Tutorial/HomePage'>Learning</a>
<a class='wikilink' href='index.html'>Reference</a>
<a class='wikilink' href='http://arduino.cc/en/Main/Hardware'>Hardware</a>
<a class='wikilink' href='FAQ.html'>FAQ</a>
</p>
<p class='vspace'></p>
</div>
</div>
<!--/PageLeftFmt-->
<div id="pagetext">
<!--PageText-->
<div id='wikitext'>
<p><strong>Reference</strong> &nbsp; <a class='wikilink' href='index.html'>Language</a> | <a class='wikilink' href='Libraries.html'>Libraries</a> | <a class='wikilink' href='Comparison.html'>Comparison</a> | <a class='wikilink' href='Changes.html'>Changes</a>
</p>
<p class='vspace'></p><p><a class='wikilink' href='Ethernet.html'>Ethernet</a> : <em><span class='wikiword'>EthernetClient</span></em>
</p>
<p class='vspace'></p><h2><span class='wikiword'>EthernetClient</span>()</h2>
<h4>Description</h4>
<p>Creates a client which can connect to a specified internet IP address and port (defined in the <a class='wikilink' href='ClientConnect.html'>client.connect()</a> function).
</p>
<p class='vspace'></p><h4>Syntax</h4>
<p><span class='wikiword'>EthernetClient</span>()
</p>
<p class='vspace'></p><h4>Parameters</h4>
<p>None
</p>
<p class='vspace'></p><h4>Example</h4>
<p>
<div class='sourceblock ' id='sourceblock1'>
<div class='sourceblocktext'><div class="arduino"><span class="co2">#include &lt;Ethernet.h&gt;</span><br />
<span class="co2">#include &lt;SPI.h&gt;</span><br />
<br />
<br />
<span class="kw1">byte</span> mac<span class="br0">&#91;</span><span class="br0">&#93;</span> <span class="sy0">=</span> <span class="br0">&#123;</span> <span class="nu12">0xDE</span><span class="sy0">,</span> <span class="nu12">0xAD</span><span class="sy0">,</span> <span class="nu12">0xBE</span><span class="sy0">,</span> <span class="nu12">0xEF</span><span class="sy0">,</span> <span class="nu12">0xFE</span><span class="sy0">,</span> <span class="nu12">0xED</span> <span class="br0">&#125;</span><span class="sy0">;</span><br />
<span class="kw1">byte</span> ip<span class="br0">&#91;</span><span class="br0">&#93;</span> <span class="sy0">=</span> <span class="br0">&#123;</span> <span class="nu0">10</span><span class="sy0">,</span> <span class="nu0">0</span><span class="sy0">,</span> <span class="nu0">0</span><span class="sy0">,</span> <span class="nu0">177</span> <span class="br0">&#125;</span><span class="sy0">;</span><br />
<span class="kw1">byte</span> server<span class="br0">&#91;</span><span class="br0">&#93;</span> <span class="sy0">=</span> <span class="br0">&#123;</span> <span class="nu0">64</span><span class="sy0">,</span> <span class="nu0">233</span><span class="sy0">,</span> <span class="nu0">187</span><span class="sy0">,</span> <span class="nu0">99</span> <span class="br0">&#125;</span><span class="sy0">;</span> <span class="co1">// Google</span><br />
<br />
EthernetClient client<span class="sy0">;</span><br />
<br />
<span class="kw1">void</span> <span class="kw3">setup</span><span class="br0">&#40;</span><span class="br0">&#41;</span><br />
<span class="br0">&#123;</span><br />
&nbsp; Ethernet.<span class="kw1">begin</span><span class="br0">&#40;</span>mac<span class="sy0">,</span> ip<span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; <span class="kw1">Serial</span>.<span class="kw1">begin</span><span class="br0">&#40;</span><span class="nu0">9600</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
<br />
&nbsp; <span class="kw1">delay</span><span class="br0">&#40;</span><span class="nu0">1000</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
<br />
&nbsp; <span class="kw1">Serial</span>.<span class="kw1">println</span><span class="br0">&#40;</span><span class="st0">&quot;connecting...&quot;</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
<br />
&nbsp; <span class="kw1">if</span> <span class="br0">&#40;</span>client.<span class="kw1">connect</span><span class="br0">&#40;</span>server<span class="sy0">,</span> <span class="nu0">80</span><span class="br0">&#41;</span><span class="br0">&#41;</span> <span class="br0">&#123;</span><br />
&nbsp; &nbsp; <span class="kw1">Serial</span>.<span class="kw1">println</span><span class="br0">&#40;</span><span class="st0">&quot;connected&quot;</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; client.<span class="kw1">println</span><span class="br0">&#40;</span><span class="st0">&quot;GET /search?q=arduino HTTP/1.0&quot;</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; client.<span class="kw1">println</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; <span class="br0">&#125;</span> <span class="kw1">else</span> <span class="br0">&#123;</span><br />
&nbsp; &nbsp; <span class="kw1">Serial</span>.<span class="kw1">println</span><span class="br0">&#40;</span><span class="st0">&quot;connection failed&quot;</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; <span class="br0">&#125;</span><br />
<span class="br0">&#125;</span><br />
<br />
<span class="kw1">void</span> <span class="kw3">loop</span><span class="br0">&#40;</span><span class="br0">&#41;</span><br />
<span class="br0">&#123;</span><br />
&nbsp; <span class="kw1">if</span> <span class="br0">&#40;</span>client.<span class="kw1">available</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="br0">&#41;</span> <span class="br0">&#123;</span><br />
&nbsp; &nbsp; <span class="kw1">char</span> c <span class="sy0">=</span> client.<span class="kw1">read</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; <span class="kw1">Serial</span>.<span class="kw1">print</span><span class="br0">&#40;</span>c<span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; <span class="br0">&#125;</span><br />
<br />
&nbsp; <span class="kw1">if</span> <span class="br0">&#40;</span><span class="sy0">!</span>client.<span class="kw1">connected</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="br0">&#41;</span> <span class="br0">&#123;</span><br />
&nbsp; &nbsp; <span class="kw1">Serial</span>.<span class="kw1">println</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; <span class="kw1">Serial</span>.<span class="kw1">println</span><span class="br0">&#40;</span><span class="st0">&quot;disconnecting.&quot;</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; client.<span class="kw1">stop</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; <span class="kw1">for</span><span class="br0">&#40;</span><span class="sy0">;;</span><span class="br0">&#41;</span><br />
&nbsp; &nbsp; &nbsp; <span class="sy0">;</span><br />
&nbsp; <span class="br0">&#125;</span><br />
<span class="br0">&#125;</span></div></div>
<div class='sourceblocklink'><a href='#' type='text/plain'>[Get Code]</a></div>
</div>
<a class='wikilink' href='index.html'>Reference Home</a>
</p>
<p class='vspace'></p><p><em>Corrections, suggestions, and new documentation should be posted to the <a class='urllink' href='http://arduino.cc/forum/index.php/board,23.0.html' rel='nofollow'>Forum</a>.</em>
</p>
<p class='vspace'></p><p>The text of the Arduino reference is licensed under a
<a class='urllink' href='http://creativecommons.org/licenses/by-sa/3.0/' rel='nofollow'>Creative Commons Attribution-ShareAlike 3.0 License</a>. Code samples in the reference are released into the public domain.
</p>
</div>
</div>
<!--PageFooterFmt-->
<div id="pagefooter">
&copy;Arduino |
<a href='#'>Edit Page</a> | <a href='#'>Page History</a> | <a href='#' target='_blank'>Printable View</a> | <a href='http://arduino.cc/en/Site/AllRecentChanges'>All Recent Site Changes</a>
</div>
<!--/PageFooterFmt-->
</div>
</body>
</html>

View File

@@ -0,0 +1,194 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>Arduino Reference - EthernetIPAddress </title>
<link rel="shortcut icon" type="image/x-icon" href="http://arduino.cc/en/favicon.png">
<link rel='stylesheet' href='arduinoWideRender.css'
type='text/css' />
<!--HeaderText--><style type='text/css'><!--
ul, ol, pre, dl, p { margin-top:0px; margin-bottom:0px; }
code { white-space: nowrap; }
.vspace { margin-top:1.33em; }
.indent { margin-left:40px; }
.outdent { margin-left:40px; text-indent:-40px; }
a.createlinktext { text-decoration:none; border-bottom:1px dotted gray; }
a.createlink { text-decoration:none; position:relative; top:-0.5em;
font-weight:bold; font-size:smaller; border-bottom:none; }
img { border:0px; }
.editconflict { color:green;
font-style:italic; margin-top:1.33em; margin-bottom:1.33em; }
table.markup { border: 2px dotted #ccf; width:90%; }
td.markup1, td.markup2 { padding-left:10px; padding-right:10px; }
td.markup1 { border-bottom: 1px solid #ccf; }
div.faq { margin-left:2em; }
div.faq p.question { margin: 1em 0 0.75em -2em; font-weight:bold; }
div.faq hr { margin-left: -2em; }
.frame
{ border:1px solid #cccccc; padding:4px; background-color:#f9f9f9; }
.lfloat { float:left; margin-right:0.5em; }
.rfloat { float:right; margin-left:0.5em; }
a.varlink { text-decoration:none; }
/**
* GeSHi (C) 2004 - 2007 Nigel McNie, 2007 - 2008 Benny Baumann
* (http://qbnz.com/highlighter/ and http://geshi.org/)
*/
.arduino {font-family:monospace;}
.arduino .imp {font-weight: bold; color: red;}
.arduino .kw1 {color: #CC6600;}
.arduino .kw2 {color: #006699;}
.arduino .kw3 {color: #CC6600; font-weight: bold;}
.arduino .co1 {color: #7E7E7E; font-style: italic;}
.arduino .co2 {color: #7E7E7E;}
.arduino .coMULTI {color: #7E7E7E; font-style: italic;}
.arduino .es0 {color: #000099; font-weight: bold;}
.arduino .es1 {color: #000099; font-weight: bold;}
.arduino .es2 {color: #660099; font-weight: bold;}
.arduino .es3 {color: #660099; font-weight: bold;}
.arduino .es4 {color: #660099; font-weight: bold;}
.arduino .es5 {color: #006699; font-weight: bold;}
.arduino .br0 {color: #000000;}
.arduino .sy0 {color: #000000;}
.arduino .st0 {color: #0066CC;}
.arduino .nu0 {color: #000000;}
.arduino .nu6 {color: #208080;}
.arduino .nu8 {color: #208080;}
.arduino .nu12 {color: #208080;}
.arduino .nu16 {color:#800080;}
.arduino .nu17 {color:#800080;}
.arduino .nu18 {color:#800080;}
.arduino .nu19 {color:#800080;}
.arduino .me1 {color: #ff1493;}
.arduino .me2 {color: #ff1493;}
.arduino span.xtra { display:block; }
.sourceblocklink {
text-align: right;
font-size: smaller;
}
.sourceblocktext {
padding: 0.5em;
color: #000000;
background-color: #ffffff;
}
.sourceblocktext div {
font-family: monospace;
font-size: small;
line-height: 1;
height: 1%;
}
.sourceblocktext div.head,
.sourceblocktext div.foot {
font: italic medium serif;
padding: 0.5em;
}
--></style> <meta name='robots' content='index,follow' />
<meta name="verify-v1" content="TtxFIEJAB6zdJ509wLxjnapQzKAMNm9u0Wj4ho6wxIY=" />
</head>
<body>
<div id="page">
<!--PageHeaderFmt-->
<div id="pageheader">
<div class="title"><a href='http://arduino.cc/en'>Arduino</a></div>
</div>
<!--/PageHeaderFmt-->
<!--PageLeftFmt-->
<div id="pagenav">
<div id="navbar">
<p><a class='wikilink' href='http://arduino.cc/en/Main/Buy'>Buy</a>
<a class='wikilink' href='http://arduino.cc/en/Main/Software'>Download</a>
<a class='wikilink' href='Guide_index.html'>Getting Started</a>
<a class='wikilink' href='http://arduino.cc/en/Tutorial/HomePage'>Learning</a>
<a class='wikilink' href='index.html'>Reference</a>
<a class='wikilink' href='http://arduino.cc/en/Main/Hardware'>Hardware</a>
<a class='wikilink' href='FAQ.html'>FAQ</a>
</p>
<p class='vspace'></p>
</div>
</div>
<!--/PageLeftFmt-->
<div id="pagetext">
<!--PageText-->
<div id='wikitext'>
<p><strong>Reference</strong> &nbsp; <a class='wikilink' href='index.html'>Language</a> | <a class='wikilink' href='Libraries.html'>Libraries</a> | <a class='wikilink' href='Comparison.html'>Comparison</a> | <a class='wikilink' href='Changes.html'>Changes</a>
</p>
<p class='vspace'></p><p><a class='wikilink' href='Ethernet.html'>Ethernet</a> : <em><span class='wikiword'>IPAddress</span></em> class
</p>
<p class='vspace'></p><h2><span class='wikiword'>IPAddress</span>()</h2>
<h4>Description</h4>
<p>Defines an IP address. It can be used to declare both local and remote addresses.
</p>
<p class='vspace'></p><h4>Syntax</h4>
<p><span class='wikiword'>IPAddress</span>(address);
</p>
<p class='vspace'></p><h4>Parameters</h4>
<p><strong>address</strong>: a comma delimited list representing the address (4 bytes, ex. 192, 168, 1, 1)
</p>
<p class='vspace'></p><h4>Returns</h4>
<p>None
</p>
<p class='vspace'></p><h4>Example</h4>
<p>
<div class='sourceblock ' id='sourceblock1'>
<div class='sourceblocktext'><div class="arduino"><span class="co2">#include &lt;Ethernet.h&gt;</span><br />
<br />
<span class="co1">// network configuration. &nbsp;gateway and subnet are optional.</span><br />
<br />
&nbsp;<span class="co1">// the media access control (ethernet hardware) address for the shield:</span><br />
<span class="kw1">byte</span> mac<span class="br0">&#91;</span><span class="br0">&#93;</span> <span class="sy0">=</span> <span class="br0">&#123;</span> <span class="nu12">0xDE</span><span class="sy0">,</span> <span class="nu12">0xAD</span><span class="sy0">,</span> <span class="nu12">0xBE</span><span class="sy0">,</span> <span class="nu12">0xEF</span><span class="sy0">,</span> <span class="nu12">0xFE</span><span class="sy0">,</span> <span class="nu12">0xED</span> <span class="br0">&#125;</span><span class="sy0">;</span> &nbsp;<br />
<span class="co1">// the router's gateway address:</span><br />
<span class="kw1">byte</span> gateway<span class="br0">&#91;</span><span class="br0">&#93;</span> <span class="sy0">=</span> <span class="br0">&#123;</span> <span class="nu0">10</span><span class="sy0">,</span> <span class="nu0">0</span><span class="sy0">,</span> <span class="nu0">0</span><span class="sy0">,</span> <span class="nu0">1</span> <span class="br0">&#125;</span><span class="sy0">;</span><br />
<span class="co1">// the subnet:</span><br />
<span class="kw1">byte</span> subnet<span class="br0">&#91;</span><span class="br0">&#93;</span> <span class="sy0">=</span> <span class="br0">&#123;</span> <span class="nu0">255</span><span class="sy0">,</span> <span class="nu0">255</span><span class="sy0">,</span> <span class="nu0">0</span><span class="sy0">,</span> <span class="nu0">0</span> <span class="br0">&#125;</span><span class="sy0">;</span><br />
<br />
EthernetServer server <span class="sy0">=</span> EthernetServer<span class="br0">&#40;</span><span class="nu0">23</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
<br />
<span class="co1">//the IP address is dependent on your network</span><br />
IPAddress ip<span class="br0">&#40;</span><span class="nu0">192</span><span class="sy0">,</span><span class="nu0">168</span><span class="sy0">,</span><span class="nu0">1</span><span class="sy0">,</span><span class="nu0">1</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
<br />
<span class="kw1">void</span> <span class="kw3">setup</span><span class="br0">&#40;</span><span class="br0">&#41;</span><br />
<span class="br0">&#123;</span><br />
&nbsp; <span class="co1">// initialize the ethernet device</span><br />
&nbsp; Ethernet.<span class="kw1">begin</span><span class="br0">&#40;</span>mac<span class="sy0">,</span> ip<span class="sy0">,</span> gateway<span class="sy0">,</span> subnet<span class="br0">&#41;</span><span class="sy0">;</span><br />
<br />
&nbsp; <span class="co1">// start listening for clients</span><br />
&nbsp; server.<span class="kw1">begin</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
<span class="br0">&#125;</span><br />
<br />
<span class="kw1">void</span> <span class="kw3">loop</span><span class="br0">&#40;</span><span class="br0">&#41;</span><br />
<span class="br0">&#123;</span><br />
&nbsp; <span class="co1">//print out the IP address</span><br />
&nbsp; <span class="kw1">Serial</span>.<span class="kw1">println</span><span class="br0">&#40;</span>myIPaddress<span class="br0">&#41;</span><span class="sy0">;</span><br />
<span class="br0">&#125;</span></div></div>
<div class='sourceblocklink'><a href='#' type='text/plain'>[Get Code]</a></div>
</div>
<a class='wikilink' href='index.html'>Reference Home</a>
</p>
<p class='vspace'></p><p><em>Corrections, suggestions, and new documentation should be posted to the <a class='urllink' href='http://arduino.cc/forum/index.php/board,23.0.html' rel='nofollow'>Forum</a>.</em>
</p>
<p class='vspace'></p><p>The text of the Arduino reference is licensed under a
<a class='urllink' href='http://creativecommons.org/licenses/by-sa/3.0/' rel='nofollow'>Creative Commons Attribution-ShareAlike 3.0 License</a>. Code samples in the reference are released into the public domain.
</p>
</div>
</div>
<!--PageFooterFmt-->
<div id="pagefooter">
&copy;Arduino |
<a href='#'>Edit Page</a> | <a href='#'>Page History</a> | <a href='#' target='_blank'>Printable View</a> | <a href='http://arduino.cc/en/Site/AllRecentChanges'>All Recent Site Changes</a>
</div>
<!--/PageFooterFmt-->
</div>
</body>
</html>

View File

@@ -0,0 +1,195 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>Arduino Reference - EthernetLocalIP </title>
<link rel="shortcut icon" type="image/x-icon" href="http://arduino.cc/en/favicon.png">
<link rel='stylesheet' href='arduinoWideRender.css'
type='text/css' />
<!--HeaderText--><style type='text/css'><!--
ul, ol, pre, dl, p { margin-top:0px; margin-bottom:0px; }
code { white-space: nowrap; }
.vspace { margin-top:1.33em; }
.indent { margin-left:40px; }
.outdent { margin-left:40px; text-indent:-40px; }
a.createlinktext { text-decoration:none; border-bottom:1px dotted gray; }
a.createlink { text-decoration:none; position:relative; top:-0.5em;
font-weight:bold; font-size:smaller; border-bottom:none; }
img { border:0px; }
.editconflict { color:green;
font-style:italic; margin-top:1.33em; margin-bottom:1.33em; }
table.markup { border: 2px dotted #ccf; width:90%; }
td.markup1, td.markup2 { padding-left:10px; padding-right:10px; }
td.markup1 { border-bottom: 1px solid #ccf; }
div.faq { margin-left:2em; }
div.faq p.question { margin: 1em 0 0.75em -2em; font-weight:bold; }
div.faq hr { margin-left: -2em; }
.frame
{ border:1px solid #cccccc; padding:4px; background-color:#f9f9f9; }
.lfloat { float:left; margin-right:0.5em; }
.rfloat { float:right; margin-left:0.5em; }
a.varlink { text-decoration:none; }
/**
* GeSHi (C) 2004 - 2007 Nigel McNie, 2007 - 2008 Benny Baumann
* (http://qbnz.com/highlighter/ and http://geshi.org/)
*/
.arduino {font-family:monospace;}
.arduino .imp {font-weight: bold; color: red;}
.arduino .kw1 {color: #CC6600;}
.arduino .kw2 {color: #006699;}
.arduino .kw3 {color: #CC6600; font-weight: bold;}
.arduino .co1 {color: #7E7E7E; font-style: italic;}
.arduino .co2 {color: #7E7E7E;}
.arduino .coMULTI {color: #7E7E7E; font-style: italic;}
.arduino .es0 {color: #000099; font-weight: bold;}
.arduino .es1 {color: #000099; font-weight: bold;}
.arduino .es2 {color: #660099; font-weight: bold;}
.arduino .es3 {color: #660099; font-weight: bold;}
.arduino .es4 {color: #660099; font-weight: bold;}
.arduino .es5 {color: #006699; font-weight: bold;}
.arduino .br0 {color: #000000;}
.arduino .sy0 {color: #000000;}
.arduino .st0 {color: #0066CC;}
.arduino .nu0 {color: #000000;}
.arduino .nu6 {color: #208080;}
.arduino .nu8 {color: #208080;}
.arduino .nu12 {color: #208080;}
.arduino .nu16 {color:#800080;}
.arduino .nu17 {color:#800080;}
.arduino .nu18 {color:#800080;}
.arduino .nu19 {color:#800080;}
.arduino .me1 {color: #ff1493;}
.arduino .me2 {color: #ff1493;}
.arduino span.xtra { display:block; }
.sourceblocklink {
text-align: right;
font-size: smaller;
}
.sourceblocktext {
padding: 0.5em;
color: #000000;
background-color: #ffffff;
}
.sourceblocktext div {
font-family: monospace;
font-size: small;
line-height: 1;
height: 1%;
}
.sourceblocktext div.head,
.sourceblocktext div.foot {
font: italic medium serif;
padding: 0.5em;
}
--></style> <meta name='robots' content='index,follow' />
<meta name="verify-v1" content="TtxFIEJAB6zdJ509wLxjnapQzKAMNm9u0Wj4ho6wxIY=" />
</head>
<body>
<div id="page">
<!--PageHeaderFmt-->
<div id="pageheader">
<div class="title"><a href='http://arduino.cc/en'>Arduino</a></div>
</div>
<!--/PageHeaderFmt-->
<!--PageLeftFmt-->
<div id="pagenav">
<div id="navbar">
<p><a class='wikilink' href='http://arduino.cc/en/Main/Buy'>Buy</a>
<a class='wikilink' href='http://arduino.cc/en/Main/Software'>Download</a>
<a class='wikilink' href='Guide_index.html'>Getting Started</a>
<a class='wikilink' href='http://arduino.cc/en/Tutorial/HomePage'>Learning</a>
<a class='wikilink' href='index.html'>Reference</a>
<a class='wikilink' href='http://arduino.cc/en/Main/Hardware'>Hardware</a>
<a class='wikilink' href='FAQ.html'>FAQ</a>
</p>
<p class='vspace'></p>
</div>
</div>
<!--/PageLeftFmt-->
<div id="pagetext">
<!--PageText-->
<div id='wikitext'>
<p><strong>Reference</strong> &nbsp; <a class='wikilink' href='index.html'>Language</a> | <a class='wikilink' href='Libraries.html'>Libraries</a> | <a class='wikilink' href='Comparison.html'>Comparison</a> | <a class='wikilink' href='Changes.html'>Changes</a>
</p>
<p class='vspace'></p><p><a class='wikilink' href='Ethernet.html'>Ethernet</a>
</p>
<p class='vspace'></p><h2>Ethernet.localIP()</h2>
<h4>Description</h4>
<p>Obtains the IP address of the Ethernet shield. Useful when the address is auto assigned through DHCP.
</p>
<p class='vspace'></p><h4>Syntax</h4>
<p>Ethernet.localIP();
</p>
<p class='vspace'></p><h4>Parameters</h4>
<p>none
</p>
<p class='vspace'></p><h4>Returns</h4>
<p>the IP address
</p>
<p class='vspace'></p><h4>Example</h4>
<p>
<div class='sourceblock ' id='sourceblock1'>
<div class='sourceblocktext'><div class="arduino"><span class="co2">#include &lt;SPI.h&gt;</span><br />
<span class="co2">#include &lt;Ethernet.h&gt;</span><br />
<br />
<span class="co1">// Enter a MAC address for your controller below.</span><br />
<span class="co1">// Newer Ethernet shields have a MAC address printed on a sticker on the shield</span><br />
<span class="kw1">byte</span> mac<span class="br0">&#91;</span><span class="br0">&#93;</span> <span class="sy0">=</span> <span class="br0">&#123;</span> &nbsp;<br />
&nbsp; <span class="nu12">0x00</span><span class="sy0">,</span> <span class="nu12">0xAA</span><span class="sy0">,</span> <span class="nu12">0xBB</span><span class="sy0">,</span> <span class="nu12">0xCC</span><span class="sy0">,</span> <span class="nu12">0xDE</span><span class="sy0">,</span> <span class="nu12">0x02</span> <span class="br0">&#125;</span><span class="sy0">;</span><br />
<br />
<span class="co1">// Initialize the Ethernet client library</span><br />
<span class="co1">// with the IP address and port of the server </span><br />
<span class="co1">// that you want to connect to (port 80 is default for HTTP):</span><br />
EthernetClient client<span class="sy0">;</span><br />
<br />
<span class="kw1">void</span> <span class="kw3">setup</span><span class="br0">&#40;</span><span class="br0">&#41;</span> <span class="br0">&#123;</span><br />
&nbsp; <span class="co1">// start the serial library:</span><br />
&nbsp; <span class="kw1">Serial</span>.<span class="kw1">begin</span><span class="br0">&#40;</span><span class="nu0">9600</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; <span class="co1">// start the Ethernet connection:</span><br />
&nbsp; <span class="kw1">if</span> <span class="br0">&#40;</span>Ethernet.<span class="kw1">begin</span><span class="br0">&#40;</span>mac<span class="br0">&#41;</span> <span class="sy0">==</span> <span class="nu0">0</span><span class="br0">&#41;</span> <span class="br0">&#123;</span><br />
&nbsp; &nbsp; <span class="kw1">Serial</span>.<span class="kw1">println</span><span class="br0">&#40;</span><span class="st0">&quot;Failed to configure Ethernet using DHCP&quot;</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; <span class="co1">// no point in carrying on, so do nothing forevermore:</span><br />
&nbsp; &nbsp; <span class="kw1">for</span><span class="br0">&#40;</span><span class="sy0">;;</span><span class="br0">&#41;</span><br />
&nbsp; &nbsp; &nbsp; <span class="sy0">;</span><br />
&nbsp; <span class="br0">&#125;</span><br />
&nbsp; <span class="co1">// print your local IP address:</span><br />
&nbsp; <span class="kw1">Serial</span>.<span class="kw1">println</span><span class="br0">&#40;</span>Ethernet.<span class="me1">localIP</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
<br />
<span class="br0">&#125;</span><br />
<br />
<span class="kw1">void</span> <span class="kw3">loop</span><span class="br0">&#40;</span><span class="br0">&#41;</span> <span class="br0">&#123;</span><br />
<br />
<span class="br0">&#125;</span></div></div>
<div class='sourceblocklink'><a href='#' type='text/plain'>[Get Code]</a></div>
</div>
<a class='wikilink' href='index.html'>Reference Home</a>
</p>
<p class='vspace'></p><p><em>Corrections, suggestions, and new documentation should be posted to the <a class='urllink' href='http://arduino.cc/forum/index.php/board,23.0.html' rel='nofollow'>Forum</a>.</em>
</p>
<p class='vspace'></p><p>The text of the Arduino reference is licensed under a
<a class='urllink' href='http://creativecommons.org/licenses/by-sa/3.0/' rel='nofollow'>Creative Commons Attribution-ShareAlike 3.0 License</a>. Code samples in the reference are released into the public domain.
</p>
</div>
</div>
<!--PageFooterFmt-->
<div id="pagefooter">
&copy;Arduino |
<a href='#'>Edit Page</a> | <a href='#'>Page History</a> | <a href='#' target='_blank'>Printable View</a> | <a href='http://arduino.cc/en/Site/AllRecentChanges'>All Recent Site Changes</a>
</div>
<!--/PageFooterFmt-->
</div>
</body>
</html>

View File

@@ -0,0 +1,200 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>Arduino Reference - EthernetServer </title>
<link rel="shortcut icon" type="image/x-icon" href="http://arduino.cc/en/favicon.png">
<link rel='stylesheet' href='arduinoWideRender.css'
type='text/css' />
<!--HeaderText--><style type='text/css'><!--
ul, ol, pre, dl, p { margin-top:0px; margin-bottom:0px; }
code { white-space: nowrap; }
.vspace { margin-top:1.33em; }
.indent { margin-left:40px; }
.outdent { margin-left:40px; text-indent:-40px; }
a.createlinktext { text-decoration:none; border-bottom:1px dotted gray; }
a.createlink { text-decoration:none; position:relative; top:-0.5em;
font-weight:bold; font-size:smaller; border-bottom:none; }
img { border:0px; }
.editconflict { color:green;
font-style:italic; margin-top:1.33em; margin-bottom:1.33em; }
table.markup { border: 2px dotted #ccf; width:90%; }
td.markup1, td.markup2 { padding-left:10px; padding-right:10px; }
td.markup1 { border-bottom: 1px solid #ccf; }
div.faq { margin-left:2em; }
div.faq p.question { margin: 1em 0 0.75em -2em; font-weight:bold; }
div.faq hr { margin-left: -2em; }
.frame
{ border:1px solid #cccccc; padding:4px; background-color:#f9f9f9; }
.lfloat { float:left; margin-right:0.5em; }
.rfloat { float:right; margin-left:0.5em; }
a.varlink { text-decoration:none; }
/**
* GeSHi (C) 2004 - 2007 Nigel McNie, 2007 - 2008 Benny Baumann
* (http://qbnz.com/highlighter/ and http://geshi.org/)
*/
.arduino {font-family:monospace;}
.arduino .imp {font-weight: bold; color: red;}
.arduino .kw1 {color: #CC6600;}
.arduino .kw2 {color: #006699;}
.arduino .kw3 {color: #CC6600; font-weight: bold;}
.arduino .co1 {color: #7E7E7E; font-style: italic;}
.arduino .co2 {color: #7E7E7E;}
.arduino .coMULTI {color: #7E7E7E; font-style: italic;}
.arduino .es0 {color: #000099; font-weight: bold;}
.arduino .es1 {color: #000099; font-weight: bold;}
.arduino .es2 {color: #660099; font-weight: bold;}
.arduino .es3 {color: #660099; font-weight: bold;}
.arduino .es4 {color: #660099; font-weight: bold;}
.arduino .es5 {color: #006699; font-weight: bold;}
.arduino .br0 {color: #000000;}
.arduino .sy0 {color: #000000;}
.arduino .st0 {color: #0066CC;}
.arduino .nu0 {color: #000000;}
.arduino .nu6 {color: #208080;}
.arduino .nu8 {color: #208080;}
.arduino .nu12 {color: #208080;}
.arduino .nu16 {color:#800080;}
.arduino .nu17 {color:#800080;}
.arduino .nu18 {color:#800080;}
.arduino .nu19 {color:#800080;}
.arduino .me1 {color: #ff1493;}
.arduino .me2 {color: #ff1493;}
.arduino span.xtra { display:block; }
.sourceblocklink {
text-align: right;
font-size: smaller;
}
.sourceblocktext {
padding: 0.5em;
color: #000000;
background-color: #ffffff;
}
.sourceblocktext div {
font-family: monospace;
font-size: small;
line-height: 1;
height: 1%;
}
.sourceblocktext div.head,
.sourceblocktext div.foot {
font: italic medium serif;
padding: 0.5em;
}
--></style> <meta name='robots' content='index,follow' />
<meta name="verify-v1" content="TtxFIEJAB6zdJ509wLxjnapQzKAMNm9u0Wj4ho6wxIY=" />
</head>
<body>
<div id="page">
<!--PageHeaderFmt-->
<div id="pageheader">
<div class="title"><a href='http://arduino.cc/en'>Arduino</a></div>
</div>
<!--/PageHeaderFmt-->
<!--PageLeftFmt-->
<div id="pagenav">
<div id="navbar">
<p><a class='wikilink' href='http://arduino.cc/en/Main/Buy'>Buy</a>
<a class='wikilink' href='http://arduino.cc/en/Main/Software'>Download</a>
<a class='wikilink' href='Guide_index.html'>Getting Started</a>
<a class='wikilink' href='http://arduino.cc/en/Tutorial/HomePage'>Learning</a>
<a class='wikilink' href='index.html'>Reference</a>
<a class='wikilink' href='http://arduino.cc/en/Main/Hardware'>Hardware</a>
<a class='wikilink' href='FAQ.html'>FAQ</a>
</p>
<p class='vspace'></p>
</div>
</div>
<!--/PageLeftFmt-->
<div id="pagetext">
<!--PageText-->
<div id='wikitext'>
<p><strong>Reference</strong> &nbsp; <a class='wikilink' href='index.html'>Language</a> | <a class='wikilink' href='Libraries.html'>Libraries</a> | <a class='wikilink' href='Comparison.html'>Comparison</a> | <a class='wikilink' href='Changes.html'>Changes</a>
</p>
<p class='vspace'></p><p><a class='wikilink' href='Ethernet.html'>Ethernet</a> : <em><span class='wikiword'>EthernetServer</span></em>
</p>
<p class='vspace'></p><h2><span class='wikiword'>EthernetServer</span>()</h2>
<h4>Description</h4>
<p>Create a server that listens for incoming connections on the specified port.
</p>
<p class='vspace'></p><h4>Syntax</h4>
<p>Server(port);
</p>
<p class='vspace'></p><h4>Parameters</h4>
<p><strong>port</strong>: the port to listen on (int)
</p>
<p class='vspace'></p><h4>Returns</h4>
<p>None
</p>
<p class='vspace'></p><h4>Example</h4>
<p>
<div class='sourceblock ' id='sourceblock1'>
<div class='sourceblocktext'><div class="arduino"><span class="co2">#include &lt;SPI.h&gt;</span><br />
<span class="co2">#include &lt;Ethernet.h&gt;</span><br />
<br />
<span class="co1">// network configuration. &nbsp;gateway and subnet are optional.</span><br />
<br />
&nbsp;<span class="co1">// the media access control (ethernet hardware) address for the shield:</span><br />
<span class="kw1">byte</span> mac<span class="br0">&#91;</span><span class="br0">&#93;</span> <span class="sy0">=</span> <span class="br0">&#123;</span> <span class="nu12">0xDE</span><span class="sy0">,</span> <span class="nu12">0xAD</span><span class="sy0">,</span> <span class="nu12">0xBE</span><span class="sy0">,</span> <span class="nu12">0xEF</span><span class="sy0">,</span> <span class="nu12">0xFE</span><span class="sy0">,</span> <span class="nu12">0xED</span> <span class="br0">&#125;</span><span class="sy0">;</span> &nbsp;<br />
<span class="co1">//the IP address for the shield:</span><br />
<span class="kw1">byte</span> ip<span class="br0">&#91;</span><span class="br0">&#93;</span> <span class="sy0">=</span> <span class="br0">&#123;</span> <span class="nu0">10</span><span class="sy0">,</span> <span class="nu0">0</span><span class="sy0">,</span> <span class="nu0">0</span><span class="sy0">,</span> <span class="nu0">177</span> <span class="br0">&#125;</span><span class="sy0">;</span> &nbsp; &nbsp;<br />
<span class="co1">// the router's gateway address:</span><br />
<span class="kw1">byte</span> gateway<span class="br0">&#91;</span><span class="br0">&#93;</span> <span class="sy0">=</span> <span class="br0">&#123;</span> <span class="nu0">10</span><span class="sy0">,</span> <span class="nu0">0</span><span class="sy0">,</span> <span class="nu0">0</span><span class="sy0">,</span> <span class="nu0">1</span> <span class="br0">&#125;</span><span class="sy0">;</span><br />
<span class="co1">// the subnet:</span><br />
<span class="kw1">byte</span> subnet<span class="br0">&#91;</span><span class="br0">&#93;</span> <span class="sy0">=</span> <span class="br0">&#123;</span> <span class="nu0">255</span><span class="sy0">,</span> <span class="nu0">255</span><span class="sy0">,</span> <span class="nu0">0</span><span class="sy0">,</span> <span class="nu0">0</span> <span class="br0">&#125;</span><span class="sy0">;</span><br />
<br />
<span class="co1">// telnet defaults to port 23</span><br />
EthernetServer server <span class="sy0">=</span> EthernetServer<span class="br0">&#40;</span><span class="nu0">23</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
<br />
<span class="kw1">void</span> <span class="kw3">setup</span><span class="br0">&#40;</span><span class="br0">&#41;</span><br />
<span class="br0">&#123;</span><br />
&nbsp; <span class="co1">// initialize the ethernet device</span><br />
&nbsp; Ethernet.<span class="kw1">begin</span><span class="br0">&#40;</span>mac<span class="sy0">,</span> ip<span class="sy0">,</span> gateway<span class="sy0">,</span> subnet<span class="br0">&#41;</span><span class="sy0">;</span><br />
<br />
&nbsp; <span class="co1">// start listening for clients</span><br />
&nbsp; server.<span class="kw1">begin</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
<span class="br0">&#125;</span><br />
<br />
<span class="kw1">void</span> <span class="kw3">loop</span><span class="br0">&#40;</span><span class="br0">&#41;</span><br />
<span class="br0">&#123;</span><br />
&nbsp; <span class="co1">// if an incoming client connects, there will be bytes available to read:</span><br />
&nbsp; EthernetClient client <span class="sy0">=</span> server.<span class="kw1">available</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; <span class="kw1">if</span> <span class="br0">&#40;</span>client <span class="sy0">==</span> <span class="kw1">true</span><span class="br0">&#41;</span> <span class="br0">&#123;</span><br />
&nbsp; &nbsp; <span class="co1">// read bytes from the incoming client and write them back</span><br />
&nbsp; &nbsp; <span class="co1">// to any clients connected to the server:</span><br />
&nbsp; &nbsp; server.<span class="kw1">write</span><span class="br0">&#40;</span>client.<span class="kw1">read</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; <span class="br0">&#125;</span><br />
<span class="br0">&#125;</span></div></div>
<div class='sourceblocklink'><a href='#' type='text/plain'>[Get Code]</a></div>
</div>
<a class='wikilink' href='index.html'>Reference Home</a>
</p>
<p class='vspace'></p><p><em>Corrections, suggestions, and new documentation should be posted to the <a class='urllink' href='http://arduino.cc/forum/index.php/board,23.0.html' rel='nofollow'>Forum</a>.</em>
</p>
<p class='vspace'></p><p>The text of the Arduino reference is licensed under a
<a class='urllink' href='http://creativecommons.org/licenses/by-sa/3.0/' rel='nofollow'>Creative Commons Attribution-ShareAlike 3.0 License</a>. Code samples in the reference are released into the public domain.
</p>
</div>
</div>
<!--PageFooterFmt-->
<div id="pagefooter">
&copy;Arduino |
<a href='#'>Edit Page</a> | <a href='#'>Page History</a> | <a href='#' target='_blank'>Printable View</a> | <a href='http://arduino.cc/en/Site/AllRecentChanges'>All Recent Site Changes</a>
</div>
<!--/PageFooterFmt-->
</div>
</body>
</html>

View File

@@ -0,0 +1,221 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>Arduino Reference - EthernetUDPAvailable </title>
<link rel="shortcut icon" type="image/x-icon" href="http://arduino.cc/en/favicon.png">
<link rel='stylesheet' href='arduinoWideRender.css'
type='text/css' />
<!--HeaderText--><style type='text/css'><!--
ul, ol, pre, dl, p { margin-top:0px; margin-bottom:0px; }
code { white-space: nowrap; }
.vspace { margin-top:1.33em; }
.indent { margin-left:40px; }
.outdent { margin-left:40px; text-indent:-40px; }
a.createlinktext { text-decoration:none; border-bottom:1px dotted gray; }
a.createlink { text-decoration:none; position:relative; top:-0.5em;
font-weight:bold; font-size:smaller; border-bottom:none; }
img { border:0px; }
.editconflict { color:green;
font-style:italic; margin-top:1.33em; margin-bottom:1.33em; }
table.markup { border: 2px dotted #ccf; width:90%; }
td.markup1, td.markup2 { padding-left:10px; padding-right:10px; }
td.markup1 { border-bottom: 1px solid #ccf; }
div.faq { margin-left:2em; }
div.faq p.question { margin: 1em 0 0.75em -2em; font-weight:bold; }
div.faq hr { margin-left: -2em; }
.frame
{ border:1px solid #cccccc; padding:4px; background-color:#f9f9f9; }
.lfloat { float:left; margin-right:0.5em; }
.rfloat { float:right; margin-left:0.5em; }
a.varlink { text-decoration:none; }
/**
* GeSHi (C) 2004 - 2007 Nigel McNie, 2007 - 2008 Benny Baumann
* (http://qbnz.com/highlighter/ and http://geshi.org/)
*/
.arduino {font-family:monospace;}
.arduino .imp {font-weight: bold; color: red;}
.arduino .kw1 {color: #CC6600;}
.arduino .kw2 {color: #006699;}
.arduino .kw3 {color: #CC6600; font-weight: bold;}
.arduino .co1 {color: #7E7E7E; font-style: italic;}
.arduino .co2 {color: #7E7E7E;}
.arduino .coMULTI {color: #7E7E7E; font-style: italic;}
.arduino .es0 {color: #000099; font-weight: bold;}
.arduino .es1 {color: #000099; font-weight: bold;}
.arduino .es2 {color: #660099; font-weight: bold;}
.arduino .es3 {color: #660099; font-weight: bold;}
.arduino .es4 {color: #660099; font-weight: bold;}
.arduino .es5 {color: #006699; font-weight: bold;}
.arduino .br0 {color: #000000;}
.arduino .sy0 {color: #000000;}
.arduino .st0 {color: #0066CC;}
.arduino .nu0 {color: #000000;}
.arduino .nu6 {color: #208080;}
.arduino .nu8 {color: #208080;}
.arduino .nu12 {color: #208080;}
.arduino .nu16 {color:#800080;}
.arduino .nu17 {color:#800080;}
.arduino .nu18 {color:#800080;}
.arduino .nu19 {color:#800080;}
.arduino .me1 {color: #ff1493;}
.arduino .me2 {color: #ff1493;}
.arduino span.xtra { display:block; }
.sourceblocklink {
text-align: right;
font-size: smaller;
}
.sourceblocktext {
padding: 0.5em;
color: #000000;
background-color: #ffffff;
}
.sourceblocktext div {
font-family: monospace;
font-size: small;
line-height: 1;
height: 1%;
}
.sourceblocktext div.head,
.sourceblocktext div.foot {
font: italic medium serif;
padding: 0.5em;
}
--></style> <meta name='robots' content='index,follow' />
<meta name="verify-v1" content="TtxFIEJAB6zdJ509wLxjnapQzKAMNm9u0Wj4ho6wxIY=" />
</head>
<body>
<div id="page">
<!--PageHeaderFmt-->
<div id="pageheader">
<div class="title"><a href='http://arduino.cc/en'>Arduino</a></div>
</div>
<!--/PageHeaderFmt-->
<!--PageLeftFmt-->
<div id="pagenav">
<div id="navbar">
<p><a class='wikilink' href='http://arduino.cc/en/Main/Buy'>Buy</a>
<a class='wikilink' href='http://arduino.cc/en/Main/Software'>Download</a>
<a class='wikilink' href='Guide_index.html'>Getting Started</a>
<a class='wikilink' href='http://arduino.cc/en/Tutorial/HomePage'>Learning</a>
<a class='wikilink' href='index.html'>Reference</a>
<a class='wikilink' href='http://arduino.cc/en/Main/Hardware'>Hardware</a>
<a class='wikilink' href='FAQ.html'>FAQ</a>
</p>
<p class='vspace'></p>
</div>
</div>
<!--/PageLeftFmt-->
<div id="pagetext">
<!--PageText-->
<div id='wikitext'>
<p><strong>Reference</strong> &nbsp; <a class='wikilink' href='index.html'>Language</a> | <a class='wikilink' href='Libraries.html'>Libraries</a> | <a class='wikilink' href='Comparison.html'>Comparison</a> | <a class='wikilink' href='Changes.html'>Changes</a>
</p>
<p class='vspace'></p><p><a class='wikilink' href='Ethernet.html'>Ethernet</a> : <em>UDP.available()</em>
</p>
<p class='vspace'></p><h2>available()</h2>
<h4>Description</h4>
<p>Get the number of bytes (characters) available for reading from the buffer. This is data that's already arrived.
</p>
<p class='vspace'></p><p>This function can only be successfully called after <a class='wikilink' href='EthernetUDPParsePacket.html'>UDP.parsePacket()</a>.
</p>
<p class='vspace'></p><p>available() inherits from the <a class='wikilink' href='Stream.html'>Stream</a> utility class.
</p>
<p class='vspace'></p><h4>Syntax</h4>
<p><em>UDP</em>.available()
</p>
<p class='vspace'></p><h4>Parameters</h4>
<p>None
</p>
<p class='vspace'></p><h4>Returns</h4>
<p>the number of bytes available to read
</p>
<p class='vspace'></p><h4>Example</h4>
<p>
<div class='sourceblock ' id='sourceblock1'>
<div class='sourceblocktext'><div class="arduino"><span class="co2">#include &lt;SPI.h&gt; &nbsp; &nbsp; &nbsp; &nbsp;</span><br />
<span class="co2">#include &lt;Ethernet.h&gt;</span><br />
<span class="co2">#include &lt;EthernetUdp.h&gt;</span><br />
<br />
<span class="co1">// Enter a MAC address and IP address for your controller below.</span><br />
<span class="co1">// The IP address will be dependent on your local network:</span><br />
<span class="kw1">byte</span> mac<span class="br0">&#91;</span><span class="br0">&#93;</span> <span class="sy0">=</span> <span class="br0">&#123;</span> &nbsp;<br />
&nbsp; <span class="nu12">0xDE</span><span class="sy0">,</span> <span class="nu12">0xAD</span><span class="sy0">,</span> <span class="nu12">0xBE</span><span class="sy0">,</span> <span class="nu12">0xEF</span><span class="sy0">,</span> <span class="nu12">0xFE</span><span class="sy0">,</span> <span class="nu12">0xED</span> <span class="br0">&#125;</span><span class="sy0">;</span><br />
IPAddress ip<span class="br0">&#40;</span><span class="nu0">192</span><span class="sy0">,</span> <span class="nu0">168</span><span class="sy0">,</span> <span class="nu0">1</span><span class="sy0">,</span> <span class="nu0">177</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
<br />
<span class="kw1">unsigned</span> <span class="kw1">int</span> localPort <span class="sy0">=</span> <span class="nu0">8888</span><span class="sy0">;</span> &nbsp; &nbsp; &nbsp;<span class="co1">// local port to listen on</span><br />
<br />
<span class="co1">// An EthernetUDP instance to let us send and receive packets over UDP</span><br />
EthernetUDP Udp<span class="sy0">;</span><br />
<br />
<span class="kw1">char</span> packetBuffer<span class="br0">&#91;</span>UDP_TX_PACKET_MAX_SIZE<span class="br0">&#93;</span><span class="sy0">;</span> <span class="co1">//buffer to hold incoming packet,</span><br />
<br />
<span class="kw1">void</span> <span class="kw3">setup</span><span class="br0">&#40;</span><span class="br0">&#41;</span> <span class="br0">&#123;</span><br />
&nbsp; <span class="co1">// start the Ethernet and UDP:</span><br />
&nbsp; Ethernet.<span class="kw1">begin</span><span class="br0">&#40;</span>mac<span class="sy0">,</span>ip<span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; Udp.<span class="kw1">begin</span><span class="br0">&#40;</span>localPort<span class="br0">&#41;</span><span class="sy0">;</span><br />
<br />
<span class="br0">&#125;</span><br />
<br />
<span class="kw1">void</span> <span class="kw3">loop</span><span class="br0">&#40;</span><span class="br0">&#41;</span> <span class="br0">&#123;</span><br />
<br />
&nbsp; <span class="kw1">int</span> packetSize <span class="sy0">=</span> Udp.<span class="me1">parsePacket</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; <span class="kw1">if</span><span class="br0">&#40;</span>Udp.<span class="kw1">available</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="br0">&#41;</span><br />
&nbsp; <span class="br0">&#123;</span><br />
&nbsp; &nbsp; <span class="kw1">Serial</span>.<span class="kw1">print</span><span class="br0">&#40;</span><span class="st0">&quot;Received packet of size &quot;</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; <span class="kw1">Serial</span>.<span class="kw1">println</span><span class="br0">&#40;</span>packetSize<span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; <span class="kw1">Serial</span>.<span class="kw1">print</span><span class="br0">&#40;</span><span class="st0">&quot;From &quot;</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; IPAddress remote <span class="sy0">=</span> Udp.<span class="me1">remoteIP</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; <span class="kw1">for</span> <span class="br0">&#40;</span><span class="kw1">int</span> i <span class="sy0">=</span><span class="nu0">0</span><span class="sy0">;</span> i <span class="sy0">&lt;</span> <span class="nu0">4</span><span class="sy0">;</span> i<span class="sy0">++</span><span class="br0">&#41;</span><br />
&nbsp; &nbsp; <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; <span class="kw1">Serial</span>.<span class="kw1">print</span><span class="br0">&#40;</span>remote<span class="br0">&#91;</span>i<span class="br0">&#93;</span><span class="sy0">,</span> <span class="kw2">DEC</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; &nbsp; <span class="kw1">if</span> <span class="br0">&#40;</span>i <span class="sy0">&lt;</span> <span class="nu0">3</span><span class="br0">&#41;</span><br />
&nbsp; &nbsp; &nbsp; <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">Serial</span>.<span class="kw1">print</span><span class="br0">&#40;</span><span class="st0">&quot;.&quot;</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span><br />
&nbsp; &nbsp; <span class="br0">&#125;</span><br />
&nbsp; &nbsp; <span class="kw1">Serial</span>.<span class="kw1">print</span><span class="br0">&#40;</span><span class="st0">&quot;, port &quot;</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; <span class="kw1">Serial</span>.<span class="kw1">println</span><span class="br0">&#40;</span>Udp.<span class="me1">remotePort</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
<br />
&nbsp; &nbsp; <span class="co1">// read the packet into packetBufffer</span><br />
&nbsp; &nbsp; Udp.<span class="kw1">read</span><span class="br0">&#40;</span>packetBuffer<span class="sy0">,</span>UDP_TX_PACKET_MAX_SIZE<span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; <span class="kw1">Serial</span>.<span class="kw1">println</span><span class="br0">&#40;</span><span class="st0">&quot;Contents:&quot;</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; <span class="kw1">Serial</span>.<span class="kw1">println</span><span class="br0">&#40;</span>packetBuffer<span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp;<span class="br0">&#125;</span><br />
<span class="br0">&#125;</span></div></div>
<div class='sourceblocklink'><a href='#' type='text/plain'>[Get Code]</a></div>
</div>
</p>
<p class='vspace'></p><h4>See Also</h4>
<ul><li><a class='wikilink' href='StreamAvailable.html'>Stream.available()</a>
</li></ul><p><a class='wikilink' href='index.html'>Reference Home</a>
</p>
<p class='vspace'></p><p><em>Corrections, suggestions, and new documentation should be posted to the <a class='urllink' href='http://arduino.cc/forum/index.php/board,23.0.html' rel='nofollow'>Forum</a>.</em>
</p>
<p class='vspace'></p><p>The text of the Arduino reference is licensed under a
<a class='urllink' href='http://creativecommons.org/licenses/by-sa/3.0/' rel='nofollow'>Creative Commons Attribution-ShareAlike 3.0 License</a>. Code samples in the reference are released into the public domain.
</p>
</div>
</div>
<!--PageFooterFmt-->
<div id="pagefooter">
&copy;Arduino |
<a href='#'>Edit Page</a> | <a href='#'>Page History</a> | <a href='#' target='_blank'>Printable View</a> | <a href='http://arduino.cc/en/Site/AllRecentChanges'>All Recent Site Changes</a>
</div>
<!--/PageFooterFmt-->
</div>
</body>
</html>

View File

@@ -0,0 +1,189 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>Arduino Reference - EthernetUDPBegin </title>
<link rel="shortcut icon" type="image/x-icon" href="http://arduino.cc/en/favicon.png">
<link rel='stylesheet' href='arduinoWideRender.css'
type='text/css' />
<!--HeaderText--><style type='text/css'><!--
ul, ol, pre, dl, p { margin-top:0px; margin-bottom:0px; }
code { white-space: nowrap; }
.vspace { margin-top:1.33em; }
.indent { margin-left:40px; }
.outdent { margin-left:40px; text-indent:-40px; }
a.createlinktext { text-decoration:none; border-bottom:1px dotted gray; }
a.createlink { text-decoration:none; position:relative; top:-0.5em;
font-weight:bold; font-size:smaller; border-bottom:none; }
img { border:0px; }
.editconflict { color:green;
font-style:italic; margin-top:1.33em; margin-bottom:1.33em; }
table.markup { border: 2px dotted #ccf; width:90%; }
td.markup1, td.markup2 { padding-left:10px; padding-right:10px; }
td.markup1 { border-bottom: 1px solid #ccf; }
div.faq { margin-left:2em; }
div.faq p.question { margin: 1em 0 0.75em -2em; font-weight:bold; }
div.faq hr { margin-left: -2em; }
.frame
{ border:1px solid #cccccc; padding:4px; background-color:#f9f9f9; }
.lfloat { float:left; margin-right:0.5em; }
.rfloat { float:right; margin-left:0.5em; }
a.varlink { text-decoration:none; }
/**
* GeSHi (C) 2004 - 2007 Nigel McNie, 2007 - 2008 Benny Baumann
* (http://qbnz.com/highlighter/ and http://geshi.org/)
*/
.arduino {font-family:monospace;}
.arduino .imp {font-weight: bold; color: red;}
.arduino .kw1 {color: #CC6600;}
.arduino .kw2 {color: #006699;}
.arduino .kw3 {color: #CC6600; font-weight: bold;}
.arduino .co1 {color: #7E7E7E; font-style: italic;}
.arduino .co2 {color: #7E7E7E;}
.arduino .coMULTI {color: #7E7E7E; font-style: italic;}
.arduino .es0 {color: #000099; font-weight: bold;}
.arduino .es1 {color: #000099; font-weight: bold;}
.arduino .es2 {color: #660099; font-weight: bold;}
.arduino .es3 {color: #660099; font-weight: bold;}
.arduino .es4 {color: #660099; font-weight: bold;}
.arduino .es5 {color: #006699; font-weight: bold;}
.arduino .br0 {color: #000000;}
.arduino .sy0 {color: #000000;}
.arduino .st0 {color: #0066CC;}
.arduino .nu0 {color: #000000;}
.arduino .nu6 {color: #208080;}
.arduino .nu8 {color: #208080;}
.arduino .nu12 {color: #208080;}
.arduino .nu16 {color:#800080;}
.arduino .nu17 {color:#800080;}
.arduino .nu18 {color:#800080;}
.arduino .nu19 {color:#800080;}
.arduino .me1 {color: #ff1493;}
.arduino .me2 {color: #ff1493;}
.arduino span.xtra { display:block; }
.sourceblocklink {
text-align: right;
font-size: smaller;
}
.sourceblocktext {
padding: 0.5em;
color: #000000;
background-color: #ffffff;
}
.sourceblocktext div {
font-family: monospace;
font-size: small;
line-height: 1;
height: 1%;
}
.sourceblocktext div.head,
.sourceblocktext div.foot {
font: italic medium serif;
padding: 0.5em;
}
--></style> <meta name='robots' content='index,follow' />
<meta name="verify-v1" content="TtxFIEJAB6zdJ509wLxjnapQzKAMNm9u0Wj4ho6wxIY=" />
</head>
<body>
<div id="page">
<!--PageHeaderFmt-->
<div id="pageheader">
<div class="title"><a href='http://arduino.cc/en'>Arduino</a></div>
</div>
<!--/PageHeaderFmt-->
<!--PageLeftFmt-->
<div id="pagenav">
<div id="navbar">
<p><a class='wikilink' href='http://arduino.cc/en/Main/Buy'>Buy</a>
<a class='wikilink' href='http://arduino.cc/en/Main/Software'>Download</a>
<a class='wikilink' href='Guide_index.html'>Getting Started</a>
<a class='wikilink' href='http://arduino.cc/en/Tutorial/HomePage'>Learning</a>
<a class='wikilink' href='index.html'>Reference</a>
<a class='wikilink' href='http://arduino.cc/en/Main/Hardware'>Hardware</a>
<a class='wikilink' href='FAQ.html'>FAQ</a>
</p>
<p class='vspace'></p>
</div>
</div>
<!--/PageLeftFmt-->
<div id="pagetext">
<!--PageText-->
<div id='wikitext'>
<p><strong>Reference</strong> &nbsp; <a class='wikilink' href='index.html'>Language</a> | <a class='wikilink' href='Libraries.html'>Libraries</a> | <a class='wikilink' href='Comparison.html'>Comparison</a> | <a class='wikilink' href='Changes.html'>Changes</a>
</p>
<p class='vspace'></p><p><a class='wikilink' href='Ethernet.html'>Ethernet</a> : <em>UDP.begin()</em>
</p>
<p class='vspace'></p><h4>Description</h4>
<p>Initializes the ethernet UDP library and network settings.
</p>
<p class='vspace'></p><h4>Syntax</h4>
<p><span class='wikiword'>EthernetUDP</span>.begin(localPort); <br />
</p><h4>Parameters</h4>
<p><strong>localPort</strong>: the local port to listen on (int)
</p>
<p class='vspace'></p><h4>Returns</h4>
<p>None
</p>
<p class='vspace'></p><h4>Example</h4>
<pre>
<div class='sourceblock ' id='sourceblock1'>
<div class='sourceblocktext'><div class="arduino"><span class="co2">#include &lt;SPI.h&gt; &nbsp; &nbsp; &nbsp; &nbsp;</span><br />
<span class="co2">#include &lt;Ethernet.h&gt;</span><br />
<span class="co2">#include &lt;EthernetUdp.h&gt;</span><br />
<br />
<span class="co1">// Enter a MAC address and IP address for your controller below.</span><br />
<span class="co1">// The IP address will be dependent on your local network:</span><br />
<span class="kw1">byte</span> mac<span class="br0">&#91;</span><span class="br0">&#93;</span> <span class="sy0">=</span> <span class="br0">&#123;</span> &nbsp;<br />
&nbsp; <span class="nu12">0xDE</span><span class="sy0">,</span> <span class="nu12">0xAD</span><span class="sy0">,</span> <span class="nu12">0xBE</span><span class="sy0">,</span> <span class="nu12">0xEF</span><span class="sy0">,</span> <span class="nu12">0xFE</span><span class="sy0">,</span> <span class="nu12">0xED</span> <span class="br0">&#125;</span><span class="sy0">;</span><br />
IPAddress ip<span class="br0">&#40;</span><span class="nu0">192</span><span class="sy0">,</span> <span class="nu0">168</span><span class="sy0">,</span> <span class="nu0">1</span><span class="sy0">,</span> <span class="nu0">177</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
<br />
<span class="kw1">unsigned</span> <span class="kw1">int</span> localPort <span class="sy0">=</span> <span class="nu0">8888</span><span class="sy0">;</span> &nbsp; &nbsp; &nbsp;<span class="co1">// local port to listen on</span><br />
<br />
<span class="co1">// An EthernetUDP instance to let us send and receive packets over UDP</span><br />
EthernetUDP Udp<span class="sy0">;</span><br />
<br />
<span class="kw1">void</span> <span class="kw3">setup</span><span class="br0">&#40;</span><span class="br0">&#41;</span> <span class="br0">&#123;</span><br />
&nbsp; <span class="co1">// start the Ethernet and UDP:</span><br />
&nbsp; Ethernet.<span class="kw1">begin</span><span class="br0">&#40;</span>mac<span class="sy0">,</span>ip<span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; Udp.<span class="kw1">begin</span><span class="br0">&#40;</span>localPort<span class="br0">&#41;</span><span class="sy0">;</span><br />
<br />
<span class="br0">&#125;</span><br />
<br />
<span class="kw1">void</span> <span class="kw3">loop</span><span class="br0">&#40;</span><span class="br0">&#41;</span> <span class="br0">&#123;</span><br />
<br />
<span class="br0">&#125;</span></div></div>
<div class='sourceblocklink'><a href='#' type='text/plain'>[Get Code]</a></div>
</div>
</pre><p><a class='wikilink' href='index.html'>Reference Home</a>
</p>
<p class='vspace'></p><p><em>Corrections, suggestions, and new documentation should be posted to the <a class='urllink' href='http://arduino.cc/forum/index.php/board,23.0.html' rel='nofollow'>Forum</a>.</em>
</p>
<p class='vspace'></p><p>The text of the Arduino reference is licensed under a
<a class='urllink' href='http://creativecommons.org/licenses/by-sa/3.0/' rel='nofollow'>Creative Commons Attribution-ShareAlike 3.0 License</a>. Code samples in the reference are released into the public domain.
</p>
</div>
</div>
<!--PageFooterFmt-->
<div id="pagefooter">
&copy;Arduino |
<a href='#'>Edit Page</a> | <a href='#'>Page History</a> | <a href='#' target='_blank'>Printable View</a> | <a href='http://arduino.cc/en/Site/AllRecentChanges'>All Recent Site Changes</a>
</div>
<!--/PageFooterFmt-->
</div>
</body>
</html>

View File

@@ -0,0 +1,190 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>Arduino Reference - EthernetUDPBeginPacket </title>
<link rel="shortcut icon" type="image/x-icon" href="http://arduino.cc/en/favicon.png">
<link rel='stylesheet' href='arduinoWideRender.css'
type='text/css' />
<!--HeaderText--><style type='text/css'><!--
ul, ol, pre, dl, p { margin-top:0px; margin-bottom:0px; }
code { white-space: nowrap; }
.vspace { margin-top:1.33em; }
.indent { margin-left:40px; }
.outdent { margin-left:40px; text-indent:-40px; }
a.createlinktext { text-decoration:none; border-bottom:1px dotted gray; }
a.createlink { text-decoration:none; position:relative; top:-0.5em;
font-weight:bold; font-size:smaller; border-bottom:none; }
img { border:0px; }
.editconflict { color:green;
font-style:italic; margin-top:1.33em; margin-bottom:1.33em; }
table.markup { border: 2px dotted #ccf; width:90%; }
td.markup1, td.markup2 { padding-left:10px; padding-right:10px; }
td.markup1 { border-bottom: 1px solid #ccf; }
div.faq { margin-left:2em; }
div.faq p.question { margin: 1em 0 0.75em -2em; font-weight:bold; }
div.faq hr { margin-left: -2em; }
.frame
{ border:1px solid #cccccc; padding:4px; background-color:#f9f9f9; }
.lfloat { float:left; margin-right:0.5em; }
.rfloat { float:right; margin-left:0.5em; }
a.varlink { text-decoration:none; }
/**
* GeSHi (C) 2004 - 2007 Nigel McNie, 2007 - 2008 Benny Baumann
* (http://qbnz.com/highlighter/ and http://geshi.org/)
*/
.arduino {font-family:monospace;}
.arduino .imp {font-weight: bold; color: red;}
.arduino .kw1 {color: #CC6600;}
.arduino .kw2 {color: #006699;}
.arduino .kw3 {color: #CC6600; font-weight: bold;}
.arduino .co1 {color: #7E7E7E; font-style: italic;}
.arduino .co2 {color: #7E7E7E;}
.arduino .coMULTI {color: #7E7E7E; font-style: italic;}
.arduino .es0 {color: #000099; font-weight: bold;}
.arduino .es1 {color: #000099; font-weight: bold;}
.arduino .es2 {color: #660099; font-weight: bold;}
.arduino .es3 {color: #660099; font-weight: bold;}
.arduino .es4 {color: #660099; font-weight: bold;}
.arduino .es5 {color: #006699; font-weight: bold;}
.arduino .br0 {color: #000000;}
.arduino .sy0 {color: #000000;}
.arduino .st0 {color: #0066CC;}
.arduino .nu0 {color: #000000;}
.arduino .nu6 {color: #208080;}
.arduino .nu8 {color: #208080;}
.arduino .nu12 {color: #208080;}
.arduino .nu16 {color:#800080;}
.arduino .nu17 {color:#800080;}
.arduino .nu18 {color:#800080;}
.arduino .nu19 {color:#800080;}
.arduino .me1 {color: #ff1493;}
.arduino .me2 {color: #ff1493;}
.arduino span.xtra { display:block; }
.sourceblocklink {
text-align: right;
font-size: smaller;
}
.sourceblocktext {
padding: 0.5em;
color: #000000;
background-color: #ffffff;
}
.sourceblocktext div {
font-family: monospace;
font-size: small;
line-height: 1;
height: 1%;
}
.sourceblocktext div.head,
.sourceblocktext div.foot {
font: italic medium serif;
padding: 0.5em;
}
--></style> <meta name='robots' content='index,follow' />
<meta name="verify-v1" content="TtxFIEJAB6zdJ509wLxjnapQzKAMNm9u0Wj4ho6wxIY=" />
</head>
<body>
<div id="page">
<!--PageHeaderFmt-->
<div id="pageheader">
<div class="title"><a href='http://arduino.cc/en'>Arduino</a></div>
</div>
<!--/PageHeaderFmt-->
<!--PageLeftFmt-->
<div id="pagenav">
<div id="navbar">
<p><a class='wikilink' href='http://arduino.cc/en/Main/Buy'>Buy</a>
<a class='wikilink' href='http://arduino.cc/en/Main/Software'>Download</a>
<a class='wikilink' href='Guide_index.html'>Getting Started</a>
<a class='wikilink' href='http://arduino.cc/en/Tutorial/HomePage'>Learning</a>
<a class='wikilink' href='index.html'>Reference</a>
<a class='wikilink' href='http://arduino.cc/en/Main/Hardware'>Hardware</a>
<a class='wikilink' href='FAQ.html'>FAQ</a>
</p>
<p class='vspace'></p>
</div>
</div>
<!--/PageLeftFmt-->
<div id="pagetext">
<!--PageText-->
<div id='wikitext'>
<p><strong>Reference</strong> &nbsp; <a class='wikilink' href='index.html'>Language</a> | <a class='wikilink' href='Libraries.html'>Libraries</a> | <a class='wikilink' href='Comparison.html'>Comparison</a> | <a class='wikilink' href='Changes.html'>Changes</a>
</p>
<p class='vspace'></p><p><a class='wikilink' href='Ethernet.html'>Ethernet</a> : <em>UDP.beginPacket()</em>
</p>
<p class='vspace'></p><h4>Description</h4>
<p>Starts a connection to write UDP data to the remote connection
</p>
<p class='vspace'></p><h4>Syntax</h4>
<p>UDP.beginPacket(remoteIP, remotePort); <br />
</p><h4>Parameters</h4>
<p><strong>remoteIP</strong>: the IP address of the remote connection (4 bytes)<br /><strong>remotePort</strong>: the port of the remote connection (int)<br />
</p><h4>Returns</h4>
<p>None
</p>
<p class='vspace'></p><h4>Example</h4>
<p>
<div class='sourceblock ' id='sourceblock1'>
<div class='sourceblocktext'><div class="arduino"><span class="co2">#include &lt;SPI.h&gt; &nbsp; &nbsp; &nbsp; &nbsp;</span><br />
<span class="co2">#include &lt;Ethernet.h&gt;</span><br />
<span class="co2">#include &lt;EthernetUdp.h&gt;</span><br />
<br />
<span class="co1">// Enter a MAC address and IP address for your controller below.</span><br />
<span class="co1">// The IP address will be dependent on your local network:</span><br />
<span class="kw1">byte</span> mac<span class="br0">&#91;</span><span class="br0">&#93;</span> <span class="sy0">=</span> <span class="br0">&#123;</span> &nbsp;<br />
&nbsp; <span class="nu12">0xDE</span><span class="sy0">,</span> <span class="nu12">0xAD</span><span class="sy0">,</span> <span class="nu12">0xBE</span><span class="sy0">,</span> <span class="nu12">0xEF</span><span class="sy0">,</span> <span class="nu12">0xFE</span><span class="sy0">,</span> <span class="nu12">0xED</span> <span class="br0">&#125;</span><span class="sy0">;</span><br />
IPAddress ip<span class="br0">&#40;</span><span class="nu0">192</span><span class="sy0">,</span> <span class="nu0">168</span><span class="sy0">,</span> <span class="nu0">1</span><span class="sy0">,</span> <span class="nu0">177</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
<br />
<span class="kw1">unsigned</span> <span class="kw1">int</span> localPort <span class="sy0">=</span> <span class="nu0">8888</span><span class="sy0">;</span> &nbsp; &nbsp; &nbsp;<span class="co1">// local port to listen on</span><br />
<br />
<span class="co1">// An EthernetUDP instance to let us send and receive packets over UDP</span><br />
EthernetUDP Udp<span class="sy0">;</span><br />
<br />
<span class="kw1">void</span> <span class="kw3">setup</span><span class="br0">&#40;</span><span class="br0">&#41;</span> <span class="br0">&#123;</span><br />
&nbsp; <span class="co1">// start the Ethernet and UDP:</span><br />
&nbsp; Ethernet.<span class="kw1">begin</span><span class="br0">&#40;</span>mac<span class="sy0">,</span>ip<span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; Udp.<span class="kw1">begin</span><span class="br0">&#40;</span>localPort<span class="br0">&#41;</span><span class="sy0">;</span><br />
<br />
<span class="br0">&#125;</span><br />
<br />
<span class="kw1">void</span> <span class="kw3">loop</span><span class="br0">&#40;</span><span class="br0">&#41;</span> <span class="br0">&#123;</span><br />
<br />
&nbsp; Udp.<span class="me1">beginPacket</span><span class="br0">&#40;</span>Udp.<span class="me1">remoteIP</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">,</span> Udp.<span class="me1">remotePort</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; Udp.<span class="kw1">write</span><span class="br0">&#40;</span><span class="st0">&quot;hello&quot;</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; Udp.<span class="me1">endPacket</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
<br />
<span class="br0">&#125;</span></div></div>
<div class='sourceblocklink'><a href='#' type='text/plain'>[Get Code]</a></div>
</div>
<a class='wikilink' href='index.html'>Reference Home</a>
</p>
<p class='vspace'></p><p><em>Corrections, suggestions, and new documentation should be posted to the <a class='urllink' href='http://arduino.cc/forum/index.php/board,23.0.html' rel='nofollow'>Forum</a>.</em>
</p>
<p class='vspace'></p><p>The text of the Arduino reference is licensed under a
<a class='urllink' href='http://creativecommons.org/licenses/by-sa/3.0/' rel='nofollow'>Creative Commons Attribution-ShareAlike 3.0 License</a>. Code samples in the reference are released into the public domain.
</p>
</div>
</div>
<!--PageFooterFmt-->
<div id="pagefooter">
&copy;Arduino |
<a href='#'>Edit Page</a> | <a href='#'>Page History</a> | <a href='#' target='_blank'>Printable View</a> | <a href='http://arduino.cc/en/Site/AllRecentChanges'>All Recent Site Changes</a>
</div>
<!--/PageFooterFmt-->
</div>
</body>
</html>

View File

@@ -0,0 +1,192 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>Arduino Reference - EthernetUDPEndPacket </title>
<link rel="shortcut icon" type="image/x-icon" href="http://arduino.cc/en/favicon.png">
<link rel='stylesheet' href='arduinoWideRender.css'
type='text/css' />
<!--HeaderText--><style type='text/css'><!--
ul, ol, pre, dl, p { margin-top:0px; margin-bottom:0px; }
code { white-space: nowrap; }
.vspace { margin-top:1.33em; }
.indent { margin-left:40px; }
.outdent { margin-left:40px; text-indent:-40px; }
a.createlinktext { text-decoration:none; border-bottom:1px dotted gray; }
a.createlink { text-decoration:none; position:relative; top:-0.5em;
font-weight:bold; font-size:smaller; border-bottom:none; }
img { border:0px; }
.editconflict { color:green;
font-style:italic; margin-top:1.33em; margin-bottom:1.33em; }
table.markup { border: 2px dotted #ccf; width:90%; }
td.markup1, td.markup2 { padding-left:10px; padding-right:10px; }
td.markup1 { border-bottom: 1px solid #ccf; }
div.faq { margin-left:2em; }
div.faq p.question { margin: 1em 0 0.75em -2em; font-weight:bold; }
div.faq hr { margin-left: -2em; }
.frame
{ border:1px solid #cccccc; padding:4px; background-color:#f9f9f9; }
.lfloat { float:left; margin-right:0.5em; }
.rfloat { float:right; margin-left:0.5em; }
a.varlink { text-decoration:none; }
/**
* GeSHi (C) 2004 - 2007 Nigel McNie, 2007 - 2008 Benny Baumann
* (http://qbnz.com/highlighter/ and http://geshi.org/)
*/
.arduino {font-family:monospace;}
.arduino .imp {font-weight: bold; color: red;}
.arduino .kw1 {color: #CC6600;}
.arduino .kw2 {color: #006699;}
.arduino .kw3 {color: #CC6600; font-weight: bold;}
.arduino .co1 {color: #7E7E7E; font-style: italic;}
.arduino .co2 {color: #7E7E7E;}
.arduino .coMULTI {color: #7E7E7E; font-style: italic;}
.arduino .es0 {color: #000099; font-weight: bold;}
.arduino .es1 {color: #000099; font-weight: bold;}
.arduino .es2 {color: #660099; font-weight: bold;}
.arduino .es3 {color: #660099; font-weight: bold;}
.arduino .es4 {color: #660099; font-weight: bold;}
.arduino .es5 {color: #006699; font-weight: bold;}
.arduino .br0 {color: #000000;}
.arduino .sy0 {color: #000000;}
.arduino .st0 {color: #0066CC;}
.arduino .nu0 {color: #000000;}
.arduino .nu6 {color: #208080;}
.arduino .nu8 {color: #208080;}
.arduino .nu12 {color: #208080;}
.arduino .nu16 {color:#800080;}
.arduino .nu17 {color:#800080;}
.arduino .nu18 {color:#800080;}
.arduino .nu19 {color:#800080;}
.arduino .me1 {color: #ff1493;}
.arduino .me2 {color: #ff1493;}
.arduino span.xtra { display:block; }
.sourceblocklink {
text-align: right;
font-size: smaller;
}
.sourceblocktext {
padding: 0.5em;
color: #000000;
background-color: #ffffff;
}
.sourceblocktext div {
font-family: monospace;
font-size: small;
line-height: 1;
height: 1%;
}
.sourceblocktext div.head,
.sourceblocktext div.foot {
font: italic medium serif;
padding: 0.5em;
}
--></style> <meta name='robots' content='index,follow' />
<meta name="verify-v1" content="TtxFIEJAB6zdJ509wLxjnapQzKAMNm9u0Wj4ho6wxIY=" />
</head>
<body>
<div id="page">
<!--PageHeaderFmt-->
<div id="pageheader">
<div class="title"><a href='http://arduino.cc/en'>Arduino</a></div>
</div>
<!--/PageHeaderFmt-->
<!--PageLeftFmt-->
<div id="pagenav">
<div id="navbar">
<p><a class='wikilink' href='http://arduino.cc/en/Main/Buy'>Buy</a>
<a class='wikilink' href='http://arduino.cc/en/Main/Software'>Download</a>
<a class='wikilink' href='Guide_index.html'>Getting Started</a>
<a class='wikilink' href='http://arduino.cc/en/Tutorial/HomePage'>Learning</a>
<a class='wikilink' href='index.html'>Reference</a>
<a class='wikilink' href='http://arduino.cc/en/Main/Hardware'>Hardware</a>
<a class='wikilink' href='FAQ.html'>FAQ</a>
</p>
<p class='vspace'></p>
</div>
</div>
<!--/PageLeftFmt-->
<div id="pagetext">
<!--PageText-->
<div id='wikitext'>
<p><strong>Reference</strong> &nbsp; <a class='wikilink' href='index.html'>Language</a> | <a class='wikilink' href='Libraries.html'>Libraries</a> | <a class='wikilink' href='Comparison.html'>Comparison</a> | <a class='wikilink' href='Changes.html'>Changes</a>
</p>
<p class='vspace'></p><p><a class='wikilink' href='Ethernet.html'>Ethernet</a> : <em>UDP.endPacket()</em>
</p>
<p class='vspace'></p><h4>Description</h4>
<p>Called after writing UDP data to the remote connection.
</p>
<p class='vspace'></p><h4>Syntax</h4>
<p>UDP.endPacket(); <br />
</p><h4>Parameters</h4>
<p>None
</p>
<p class='vspace'></p><h4>Returns</h4>
<p>None
</p>
<p class='vspace'></p><h4>Example</h4>
<p>
<div class='sourceblock ' id='sourceblock1'>
<div class='sourceblocktext'><div class="arduino"><span class="co2">#include &lt;SPI.h&gt; &nbsp; &nbsp; &nbsp; &nbsp;</span><br />
<span class="co2">#include &lt;Ethernet.h&gt;</span><br />
<span class="co2">#include &lt;EthernetUdp.h&gt;</span><br />
<br />
<span class="co1">// Enter a MAC address and IP address for your controller below.</span><br />
<span class="co1">// The IP address will be dependent on your local network:</span><br />
<span class="kw1">byte</span> mac<span class="br0">&#91;</span><span class="br0">&#93;</span> <span class="sy0">=</span> <span class="br0">&#123;</span> &nbsp;<br />
&nbsp; <span class="nu12">0xDE</span><span class="sy0">,</span> <span class="nu12">0xAD</span><span class="sy0">,</span> <span class="nu12">0xBE</span><span class="sy0">,</span> <span class="nu12">0xEF</span><span class="sy0">,</span> <span class="nu12">0xFE</span><span class="sy0">,</span> <span class="nu12">0xED</span> <span class="br0">&#125;</span><span class="sy0">;</span><br />
IPAddress ip<span class="br0">&#40;</span><span class="nu0">192</span><span class="sy0">,</span> <span class="nu0">168</span><span class="sy0">,</span> <span class="nu0">1</span><span class="sy0">,</span> <span class="nu0">177</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
<br />
<span class="kw1">unsigned</span> <span class="kw1">int</span> localPort <span class="sy0">=</span> <span class="nu0">8888</span><span class="sy0">;</span> &nbsp; &nbsp; &nbsp;<span class="co1">// local port to listen on</span><br />
<br />
<span class="co1">// An EthernetUDP instance to let us send and receive packets over UDP</span><br />
EthernetUDP Udp<span class="sy0">;</span><br />
<br />
<span class="kw1">void</span> <span class="kw3">setup</span><span class="br0">&#40;</span><span class="br0">&#41;</span> <span class="br0">&#123;</span><br />
&nbsp; <span class="co1">// start the Ethernet and UDP:</span><br />
&nbsp; Ethernet.<span class="kw1">begin</span><span class="br0">&#40;</span>mac<span class="sy0">,</span>ip<span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; Udp.<span class="kw1">begin</span><span class="br0">&#40;</span>localPort<span class="br0">&#41;</span><span class="sy0">;</span><br />
<br />
<span class="br0">&#125;</span><br />
<br />
<span class="kw1">void</span> <span class="kw3">loop</span><span class="br0">&#40;</span><span class="br0">&#41;</span> <span class="br0">&#123;</span><br />
<br />
&nbsp; Udp.<span class="me1">beginPacket</span><span class="br0">&#40;</span>Udp.<span class="me1">remoteIP</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">,</span> Udp.<span class="me1">remotePort</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; Udp.<span class="kw1">write</span><span class="br0">&#40;</span><span class="st0">&quot;hello&quot;</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; Udp.<span class="me1">endPacket</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
<br />
<span class="br0">&#125;</span></div></div>
<div class='sourceblocklink'><a href='#' type='text/plain'>[Get Code]</a></div>
</div>
</p>
<p class='vspace'></p><p><a class='wikilink' href='index.html'>Reference Home</a>
</p>
<p class='vspace'></p><p><em>Corrections, suggestions, and new documentation should be posted to the <a class='urllink' href='http://arduino.cc/forum/index.php/board,23.0.html' rel='nofollow'>Forum</a>.</em>
</p>
<p class='vspace'></p><p>The text of the Arduino reference is licensed under a
<a class='urllink' href='http://creativecommons.org/licenses/by-sa/3.0/' rel='nofollow'>Creative Commons Attribution-ShareAlike 3.0 License</a>. Code samples in the reference are released into the public domain.
</p>
</div>
</div>
<!--PageFooterFmt-->
<div id="pagefooter">
&copy;Arduino |
<a href='#'>Edit Page</a> | <a href='#'>Page History</a> | <a href='#' target='_blank'>Printable View</a> | <a href='http://arduino.cc/en/Site/AllRecentChanges'>All Recent Site Changes</a>
</div>
<!--/PageFooterFmt-->
</div>
</body>
</html>

View File

@@ -0,0 +1,200 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>Arduino Reference - EthernetUDPParsePacket </title>
<link rel="shortcut icon" type="image/x-icon" href="http://arduino.cc/en/favicon.png">
<link rel='stylesheet' href='arduinoWideRender.css'
type='text/css' />
<!--HeaderText--><style type='text/css'><!--
ul, ol, pre, dl, p { margin-top:0px; margin-bottom:0px; }
code { white-space: nowrap; }
.vspace { margin-top:1.33em; }
.indent { margin-left:40px; }
.outdent { margin-left:40px; text-indent:-40px; }
a.createlinktext { text-decoration:none; border-bottom:1px dotted gray; }
a.createlink { text-decoration:none; position:relative; top:-0.5em;
font-weight:bold; font-size:smaller; border-bottom:none; }
img { border:0px; }
.editconflict { color:green;
font-style:italic; margin-top:1.33em; margin-bottom:1.33em; }
table.markup { border: 2px dotted #ccf; width:90%; }
td.markup1, td.markup2 { padding-left:10px; padding-right:10px; }
td.markup1 { border-bottom: 1px solid #ccf; }
div.faq { margin-left:2em; }
div.faq p.question { margin: 1em 0 0.75em -2em; font-weight:bold; }
div.faq hr { margin-left: -2em; }
.frame
{ border:1px solid #cccccc; padding:4px; background-color:#f9f9f9; }
.lfloat { float:left; margin-right:0.5em; }
.rfloat { float:right; margin-left:0.5em; }
a.varlink { text-decoration:none; }
/**
* GeSHi (C) 2004 - 2007 Nigel McNie, 2007 - 2008 Benny Baumann
* (http://qbnz.com/highlighter/ and http://geshi.org/)
*/
.arduino {font-family:monospace;}
.arduino .imp {font-weight: bold; color: red;}
.arduino .kw1 {color: #CC6600;}
.arduino .kw2 {color: #006699;}
.arduino .kw3 {color: #CC6600; font-weight: bold;}
.arduino .co1 {color: #7E7E7E; font-style: italic;}
.arduino .co2 {color: #7E7E7E;}
.arduino .coMULTI {color: #7E7E7E; font-style: italic;}
.arduino .es0 {color: #000099; font-weight: bold;}
.arduino .es1 {color: #000099; font-weight: bold;}
.arduino .es2 {color: #660099; font-weight: bold;}
.arduino .es3 {color: #660099; font-weight: bold;}
.arduino .es4 {color: #660099; font-weight: bold;}
.arduino .es5 {color: #006699; font-weight: bold;}
.arduino .br0 {color: #000000;}
.arduino .sy0 {color: #000000;}
.arduino .st0 {color: #0066CC;}
.arduino .nu0 {color: #000000;}
.arduino .nu6 {color: #208080;}
.arduino .nu8 {color: #208080;}
.arduino .nu12 {color: #208080;}
.arduino .nu16 {color:#800080;}
.arduino .nu17 {color:#800080;}
.arduino .nu18 {color:#800080;}
.arduino .nu19 {color:#800080;}
.arduino .me1 {color: #ff1493;}
.arduino .me2 {color: #ff1493;}
.arduino span.xtra { display:block; }
.sourceblocklink {
text-align: right;
font-size: smaller;
}
.sourceblocktext {
padding: 0.5em;
color: #000000;
background-color: #ffffff;
}
.sourceblocktext div {
font-family: monospace;
font-size: small;
line-height: 1;
height: 1%;
}
.sourceblocktext div.head,
.sourceblocktext div.foot {
font: italic medium serif;
padding: 0.5em;
}
--></style> <meta name='robots' content='index,follow' />
<meta name="verify-v1" content="TtxFIEJAB6zdJ509wLxjnapQzKAMNm9u0Wj4ho6wxIY=" />
</head>
<body>
<div id="page">
<!--PageHeaderFmt-->
<div id="pageheader">
<div class="title"><a href='http://arduino.cc/en'>Arduino</a></div>
</div>
<!--/PageHeaderFmt-->
<!--PageLeftFmt-->
<div id="pagenav">
<div id="navbar">
<p><a class='wikilink' href='http://arduino.cc/en/Main/Buy'>Buy</a>
<a class='wikilink' href='http://arduino.cc/en/Main/Software'>Download</a>
<a class='wikilink' href='Guide_index.html'>Getting Started</a>
<a class='wikilink' href='http://arduino.cc/en/Tutorial/HomePage'>Learning</a>
<a class='wikilink' href='index.html'>Reference</a>
<a class='wikilink' href='http://arduino.cc/en/Main/Hardware'>Hardware</a>
<a class='wikilink' href='FAQ.html'>FAQ</a>
</p>
<p class='vspace'></p>
</div>
</div>
<!--/PageLeftFmt-->
<div id="pagetext">
<!--PageText-->
<div id='wikitext'>
<p><strong>Reference</strong> &nbsp; <a class='wikilink' href='index.html'>Language</a> | <a class='wikilink' href='Libraries.html'>Libraries</a> | <a class='wikilink' href='Comparison.html'>Comparison</a> | <a class='wikilink' href='Changes.html'>Changes</a>
</p>
<p class='vspace'></p><p><a class='wikilink' href='Ethernet.html'>Ethernet</a> : <em>UDP.parsePacket()</em>
</p>
<p class='vspace'></p><h4>Description</h4>
<p>Checks for the presence of a UDP packet, and reports the size. parsePacket() must be called before reading the buffer with <a class='wikilink' href='EthernetUDPRead.html'>UDP.read()</a>.
</p>
<p class='vspace'></p><h4>Syntax</h4>
<p>UDP.parsePacket(); <br />
</p><h4>Parameters</h4>
<p>None
</p>
<p class='vspace'></p><h4>Returns</h4>
<p>int: the size of a received UDP packet
</p>
<p class='vspace'></p><h4>Example</h4>
<p>
<div class='sourceblock ' id='sourceblock1'>
<div class='sourceblocktext'><div class="arduino"><br />
<span class="co2">#include &lt;SPI.h&gt; &nbsp; &nbsp; &nbsp; &nbsp; // needed for Arduino versions later than 0018</span><br />
<span class="co2">#include &lt;Ethernet.h&gt;</span><br />
<span class="co2">#include &lt;EthernetUdp.h&gt; &nbsp; &nbsp; &nbsp; &nbsp; // UDP library from: bjoern@cs.stanford.edu 12/30/2008</span><br />
<br />
<br />
<span class="co1">// Enter a MAC address and IP address for your controller below.</span><br />
<span class="co1">// The IP address will be dependent on your local network:</span><br />
<span class="kw1">byte</span> mac<span class="br0">&#91;</span><span class="br0">&#93;</span> <span class="sy0">=</span> <span class="br0">&#123;</span> &nbsp;<br />
&nbsp; <span class="nu12">0xDE</span><span class="sy0">,</span> <span class="nu12">0xAD</span><span class="sy0">,</span> <span class="nu12">0xBE</span><span class="sy0">,</span> <span class="nu12">0xEF</span><span class="sy0">,</span> <span class="nu12">0xFE</span><span class="sy0">,</span> <span class="nu12">0xED</span> <span class="br0">&#125;</span><span class="sy0">;</span><br />
IPAddress ip<span class="br0">&#40;</span><span class="nu0">192</span><span class="sy0">,</span> <span class="nu0">168</span><span class="sy0">,</span> <span class="nu0">1</span><span class="sy0">,</span> <span class="nu0">177</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
<br />
<span class="kw1">unsigned</span> <span class="kw1">int</span> localPort <span class="sy0">=</span> <span class="nu0">8888</span><span class="sy0">;</span> &nbsp; &nbsp; &nbsp;<span class="co1">// local port to listen on</span><br />
<br />
<span class="co1">// An EthernetUDP instance to let us send and receive packets over UDP</span><br />
EthernetUDP Udp<span class="sy0">;</span><br />
<br />
<span class="kw1">void</span> <span class="kw3">setup</span><span class="br0">&#40;</span><span class="br0">&#41;</span> <span class="br0">&#123;</span><br />
&nbsp; <span class="co1">// start the Ethernet and UDP:</span><br />
&nbsp; Ethernet.<span class="kw1">begin</span><span class="br0">&#40;</span>mac<span class="sy0">,</span>ip<span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; Udp.<span class="kw1">begin</span><span class="br0">&#40;</span>localPort<span class="br0">&#41;</span><span class="sy0">;</span><br />
<br />
&nbsp; <span class="kw1">Serial</span>.<span class="kw1">begin</span><span class="br0">&#40;</span><span class="nu0">9600</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
<span class="br0">&#125;</span><br />
<br />
<span class="kw1">void</span> <span class="kw3">loop</span><span class="br0">&#40;</span><span class="br0">&#41;</span> <span class="br0">&#123;</span><br />
&nbsp; <span class="co1">// if there's data available, read a packet</span><br />
&nbsp; <span class="kw1">int</span> packetSize <span class="sy0">=</span> Udp.<span class="me1">parsePacket</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; <span class="kw1">if</span><span class="br0">&#40;</span>packetSize<span class="br0">&#41;</span><br />
&nbsp; <span class="br0">&#123;</span><br />
&nbsp; &nbsp; <span class="kw1">Serial</span>.<span class="kw1">print</span><span class="br0">&#40;</span><span class="st0">&quot;Received packet of size &quot;</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; <span class="kw1">Serial</span>.<span class="kw1">println</span><span class="br0">&#40;</span>packetSize<span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; <span class="br0">&#125;</span><br />
&nbsp; <span class="kw1">delay</span><span class="br0">&#40;</span><span class="nu0">10</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
<span class="br0">&#125;</span></div></div>
<div class='sourceblocklink'><a href='#' type='text/plain'>[Get Code]</a></div>
</div>
</p>
<p class='vspace'></p><h4>See Also</h4>
<ul><li><a class='wikilink' href='EthernetUDPRead.html'>UDP.read()</a><br />
</li></ul><p><a class='wikilink' href='index.html'>Reference Home</a>
</p>
<p class='vspace'></p><p><em>Corrections, suggestions, and new documentation should be posted to the <a class='urllink' href='http://arduino.cc/forum/index.php/board,23.0.html' rel='nofollow'>Forum</a>.</em>
</p>
<p class='vspace'></p><p>The text of the Arduino reference is licensed under a
<a class='urllink' href='http://creativecommons.org/licenses/by-sa/3.0/' rel='nofollow'>Creative Commons Attribution-ShareAlike 3.0 License</a>. Code samples in the reference are released into the public domain.
</p>
</div>
</div>
<!--PageFooterFmt-->
<div id="pagefooter">
&copy;Arduino |
<a href='#'>Edit Page</a> | <a href='#'>Page History</a> | <a href='#' target='_blank'>Printable View</a> | <a href='http://arduino.cc/en/Site/AllRecentChanges'>All Recent Site Changes</a>
</div>
<!--/PageFooterFmt-->
</div>
</body>
</html>

View File

@@ -0,0 +1,215 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>Arduino Reference - EthernetUDPRead </title>
<link rel="shortcut icon" type="image/x-icon" href="http://arduino.cc/en/favicon.png">
<link rel='stylesheet' href='arduinoWideRender.css'
type='text/css' />
<!--HeaderText--><style type='text/css'><!--
ul, ol, pre, dl, p { margin-top:0px; margin-bottom:0px; }
code { white-space: nowrap; }
.vspace { margin-top:1.33em; }
.indent { margin-left:40px; }
.outdent { margin-left:40px; text-indent:-40px; }
a.createlinktext { text-decoration:none; border-bottom:1px dotted gray; }
a.createlink { text-decoration:none; position:relative; top:-0.5em;
font-weight:bold; font-size:smaller; border-bottom:none; }
img { border:0px; }
.editconflict { color:green;
font-style:italic; margin-top:1.33em; margin-bottom:1.33em; }
table.markup { border: 2px dotted #ccf; width:90%; }
td.markup1, td.markup2 { padding-left:10px; padding-right:10px; }
td.markup1 { border-bottom: 1px solid #ccf; }
div.faq { margin-left:2em; }
div.faq p.question { margin: 1em 0 0.75em -2em; font-weight:bold; }
div.faq hr { margin-left: -2em; }
.frame
{ border:1px solid #cccccc; padding:4px; background-color:#f9f9f9; }
.lfloat { float:left; margin-right:0.5em; }
.rfloat { float:right; margin-left:0.5em; }
a.varlink { text-decoration:none; }
/**
* GeSHi (C) 2004 - 2007 Nigel McNie, 2007 - 2008 Benny Baumann
* (http://qbnz.com/highlighter/ and http://geshi.org/)
*/
.arduino {font-family:monospace;}
.arduino .imp {font-weight: bold; color: red;}
.arduino .kw1 {color: #CC6600;}
.arduino .kw2 {color: #006699;}
.arduino .kw3 {color: #CC6600; font-weight: bold;}
.arduino .co1 {color: #7E7E7E; font-style: italic;}
.arduino .co2 {color: #7E7E7E;}
.arduino .coMULTI {color: #7E7E7E; font-style: italic;}
.arduino .es0 {color: #000099; font-weight: bold;}
.arduino .es1 {color: #000099; font-weight: bold;}
.arduino .es2 {color: #660099; font-weight: bold;}
.arduino .es3 {color: #660099; font-weight: bold;}
.arduino .es4 {color: #660099; font-weight: bold;}
.arduino .es5 {color: #006699; font-weight: bold;}
.arduino .br0 {color: #000000;}
.arduino .sy0 {color: #000000;}
.arduino .st0 {color: #0066CC;}
.arduino .nu0 {color: #000000;}
.arduino .nu6 {color: #208080;}
.arduino .nu8 {color: #208080;}
.arduino .nu12 {color: #208080;}
.arduino .nu16 {color:#800080;}
.arduino .nu17 {color:#800080;}
.arduino .nu18 {color:#800080;}
.arduino .nu19 {color:#800080;}
.arduino .me1 {color: #ff1493;}
.arduino .me2 {color: #ff1493;}
.arduino span.xtra { display:block; }
.sourceblocklink {
text-align: right;
font-size: smaller;
}
.sourceblocktext {
padding: 0.5em;
color: #000000;
background-color: #ffffff;
}
.sourceblocktext div {
font-family: monospace;
font-size: small;
line-height: 1;
height: 1%;
}
.sourceblocktext div.head,
.sourceblocktext div.foot {
font: italic medium serif;
padding: 0.5em;
}
--></style> <meta name='robots' content='index,follow' />
<meta name="verify-v1" content="TtxFIEJAB6zdJ509wLxjnapQzKAMNm9u0Wj4ho6wxIY=" />
</head>
<body>
<div id="page">
<!--PageHeaderFmt-->
<div id="pageheader">
<div class="title"><a href='http://arduino.cc/en'>Arduino</a></div>
</div>
<!--/PageHeaderFmt-->
<!--PageLeftFmt-->
<div id="pagenav">
<div id="navbar">
<p><a class='wikilink' href='http://arduino.cc/en/Main/Buy'>Buy</a>
<a class='wikilink' href='http://arduino.cc/en/Main/Software'>Download</a>
<a class='wikilink' href='Guide_index.html'>Getting Started</a>
<a class='wikilink' href='http://arduino.cc/en/Tutorial/HomePage'>Learning</a>
<a class='wikilink' href='index.html'>Reference</a>
<a class='wikilink' href='http://arduino.cc/en/Main/Hardware'>Hardware</a>
<a class='wikilink' href='FAQ.html'>FAQ</a>
</p>
<p class='vspace'></p>
</div>
</div>
<!--/PageLeftFmt-->
<div id="pagetext">
<!--PageText-->
<div id='wikitext'>
<p><strong>Reference</strong> &nbsp; <a class='wikilink' href='index.html'>Language</a> | <a class='wikilink' href='Libraries.html'>Libraries</a> | <a class='wikilink' href='Comparison.html'>Comparison</a> | <a class='wikilink' href='Changes.html'>Changes</a>
</p>
<p class='vspace'></p><p><a class='wikilink' href='Ethernet.html'>Ethernet</a> : <em>UDP.read()</em>
</p>
<p class='vspace'></p><h4>Description</h4>
<p>Reads UDP data from the specified buffer. If no arguments are given, it will return the next character in the buffer.
</p>
<p class='vspace'></p><p>This function can only be successfully called after <a class='wikilink' href='EthernetUDPParsePacket.html'>UDP.parsePacket()</a>.
</p>
<p class='vspace'></p><h4>Syntax</h4>
<p>UDP.read();<br />UDP.read(packetBuffer, <span class='wikiword'>MaxSize</span>); <br />
</p><h4>Parameters</h4>
<p><strong>packetBuffer</strong>: buffer to hold incoming packets (char)<br /><strong><span class='wikiword'>MaxSize</span></strong>: maximum size of the buffer (int)
</p>
<p class='vspace'></p><h4>Returns</h4>
<p>char : returns the characters in the buffer
</p>
<p class='vspace'></p><h4>Example</h4>
<p>
<div class='sourceblock ' id='sourceblock1'>
<div class='sourceblocktext'><div class="arduino"><span class="co2">#include &lt;SPI.h&gt; &nbsp; &nbsp; &nbsp; &nbsp;</span><br />
<span class="co2">#include &lt;Ethernet.h&gt;</span><br />
<span class="co2">#include &lt;EthernetUdp.h&gt;</span><br />
<br />
<span class="co1">// Enter a MAC address and IP address for your controller below.</span><br />
<span class="co1">// The IP address will be dependent on your local network:</span><br />
<span class="kw1">byte</span> mac<span class="br0">&#91;</span><span class="br0">&#93;</span> <span class="sy0">=</span> <span class="br0">&#123;</span> &nbsp;<br />
&nbsp; <span class="nu12">0xDE</span><span class="sy0">,</span> <span class="nu12">0xAD</span><span class="sy0">,</span> <span class="nu12">0xBE</span><span class="sy0">,</span> <span class="nu12">0xEF</span><span class="sy0">,</span> <span class="nu12">0xFE</span><span class="sy0">,</span> <span class="nu12">0xED</span> <span class="br0">&#125;</span><span class="sy0">;</span><br />
IPAddress ip<span class="br0">&#40;</span><span class="nu0">192</span><span class="sy0">,</span> <span class="nu0">168</span><span class="sy0">,</span> <span class="nu0">1</span><span class="sy0">,</span> <span class="nu0">177</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
<br />
<span class="kw1">unsigned</span> <span class="kw1">int</span> localPort <span class="sy0">=</span> <span class="nu0">8888</span><span class="sy0">;</span> &nbsp; &nbsp; &nbsp;<span class="co1">// local port to listen on</span><br />
<br />
<span class="co1">// An EthernetUDP instance to let us send and receive packets over UDP</span><br />
EthernetUDP Udp<span class="sy0">;</span><br />
<br />
<span class="kw1">char</span> packetBuffer<span class="br0">&#91;</span>UDP_TX_PACKET_MAX_SIZE<span class="br0">&#93;</span><span class="sy0">;</span> <span class="co1">//buffer to hold incoming packet,</span><br />
<br />
<span class="kw1">void</span> <span class="kw3">setup</span><span class="br0">&#40;</span><span class="br0">&#41;</span> <span class="br0">&#123;</span><br />
&nbsp; <span class="co1">// start the Ethernet and UDP:</span><br />
&nbsp; Ethernet.<span class="kw1">begin</span><span class="br0">&#40;</span>mac<span class="sy0">,</span>ip<span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; Udp.<span class="kw1">begin</span><span class="br0">&#40;</span>localPort<span class="br0">&#41;</span><span class="sy0">;</span><br />
<br />
<span class="br0">&#125;</span><br />
<br />
<span class="kw1">void</span> <span class="kw3">loop</span><span class="br0">&#40;</span><span class="br0">&#41;</span> <span class="br0">&#123;</span><br />
<br />
&nbsp; <span class="kw1">int</span> packetSize <span class="sy0">=</span> Udp.<span class="me1">parsePacket</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; <span class="kw1">if</span><span class="br0">&#40;</span>packetSize<span class="br0">&#41;</span><br />
&nbsp; <span class="br0">&#123;</span><br />
&nbsp; &nbsp; <span class="kw1">Serial</span>.<span class="kw1">print</span><span class="br0">&#40;</span><span class="st0">&quot;Received packet of size &quot;</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; <span class="kw1">Serial</span>.<span class="kw1">println</span><span class="br0">&#40;</span>packetSize<span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; <span class="kw1">Serial</span>.<span class="kw1">print</span><span class="br0">&#40;</span><span class="st0">&quot;From &quot;</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; IPAddress remote <span class="sy0">=</span> Udp.<span class="me1">remoteIP</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; <span class="kw1">for</span> <span class="br0">&#40;</span><span class="kw1">int</span> i <span class="sy0">=</span><span class="nu0">0</span><span class="sy0">;</span> i <span class="sy0">&lt;</span> <span class="nu0">4</span><span class="sy0">;</span> i<span class="sy0">++</span><span class="br0">&#41;</span><br />
&nbsp; &nbsp; <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; <span class="kw1">Serial</span>.<span class="kw1">print</span><span class="br0">&#40;</span>remote<span class="br0">&#91;</span>i<span class="br0">&#93;</span><span class="sy0">,</span> <span class="kw2">DEC</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; &nbsp; <span class="kw1">if</span> <span class="br0">&#40;</span>i <span class="sy0">&lt;</span> <span class="nu0">3</span><span class="br0">&#41;</span><br />
&nbsp; &nbsp; &nbsp; <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">Serial</span>.<span class="kw1">print</span><span class="br0">&#40;</span><span class="st0">&quot;.&quot;</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span><br />
&nbsp; &nbsp; <span class="br0">&#125;</span><br />
&nbsp; &nbsp; <span class="kw1">Serial</span>.<span class="kw1">print</span><span class="br0">&#40;</span><span class="st0">&quot;, port &quot;</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; <span class="kw1">Serial</span>.<span class="kw1">println</span><span class="br0">&#40;</span>Udp.<span class="me1">remotePort</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
<br />
&nbsp; &nbsp; <span class="co1">// read the packet into packetBufffer</span><br />
&nbsp; &nbsp; Udp.<span class="kw1">read</span><span class="br0">&#40;</span>packetBuffer<span class="sy0">,</span>UDP_TX_PACKET_MAX_SIZE<span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; <span class="kw1">Serial</span>.<span class="kw1">println</span><span class="br0">&#40;</span><span class="st0">&quot;Contents:&quot;</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; <span class="kw1">Serial</span>.<span class="kw1">println</span><span class="br0">&#40;</span>packetBuffer<span class="br0">&#41;</span><span class="sy0">;</span><br />
<span class="br0">&#125;</span><br />
<span class="br0">&#125;</span></div></div>
<div class='sourceblocklink'><a href='#' type='text/plain'>[Get Code]</a></div>
</div>
</p>
<p class='vspace'></p><p><a class='wikilink' href='index.html'>Reference Home</a>
</p>
<p class='vspace'></p><p><em>Corrections, suggestions, and new documentation should be posted to the <a class='urllink' href='http://arduino.cc/forum/index.php/board,23.0.html' rel='nofollow'>Forum</a>.</em>
</p>
<p class='vspace'></p><p>The text of the Arduino reference is licensed under a
<a class='urllink' href='http://creativecommons.org/licenses/by-sa/3.0/' rel='nofollow'>Creative Commons Attribution-ShareAlike 3.0 License</a>. Code samples in the reference are released into the public domain.
</p>
</div>
</div>
<!--PageFooterFmt-->
<div id="pagefooter">
&copy;Arduino |
<a href='#'>Edit Page</a> | <a href='#'>Page History</a> | <a href='#' target='_blank'>Printable View</a> | <a href='http://arduino.cc/en/Site/AllRecentChanges'>All Recent Site Changes</a>
</div>
<!--/PageFooterFmt-->
</div>
</body>
</html>

View File

@@ -0,0 +1,207 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>Arduino Reference - EthernetUDPRemoteIP </title>
<link rel="shortcut icon" type="image/x-icon" href="http://arduino.cc/en/favicon.png">
<link rel='stylesheet' href='arduinoWideRender.css'
type='text/css' />
<!--HeaderText--><style type='text/css'><!--
ul, ol, pre, dl, p { margin-top:0px; margin-bottom:0px; }
code { white-space: nowrap; }
.vspace { margin-top:1.33em; }
.indent { margin-left:40px; }
.outdent { margin-left:40px; text-indent:-40px; }
a.createlinktext { text-decoration:none; border-bottom:1px dotted gray; }
a.createlink { text-decoration:none; position:relative; top:-0.5em;
font-weight:bold; font-size:smaller; border-bottom:none; }
img { border:0px; }
.editconflict { color:green;
font-style:italic; margin-top:1.33em; margin-bottom:1.33em; }
table.markup { border: 2px dotted #ccf; width:90%; }
td.markup1, td.markup2 { padding-left:10px; padding-right:10px; }
td.markup1 { border-bottom: 1px solid #ccf; }
div.faq { margin-left:2em; }
div.faq p.question { margin: 1em 0 0.75em -2em; font-weight:bold; }
div.faq hr { margin-left: -2em; }
.frame
{ border:1px solid #cccccc; padding:4px; background-color:#f9f9f9; }
.lfloat { float:left; margin-right:0.5em; }
.rfloat { float:right; margin-left:0.5em; }
a.varlink { text-decoration:none; }
/**
* GeSHi (C) 2004 - 2007 Nigel McNie, 2007 - 2008 Benny Baumann
* (http://qbnz.com/highlighter/ and http://geshi.org/)
*/
.arduino {font-family:monospace;}
.arduino .imp {font-weight: bold; color: red;}
.arduino .kw1 {color: #CC6600;}
.arduino .kw2 {color: #006699;}
.arduino .kw3 {color: #CC6600; font-weight: bold;}
.arduino .co1 {color: #7E7E7E; font-style: italic;}
.arduino .co2 {color: #7E7E7E;}
.arduino .coMULTI {color: #7E7E7E; font-style: italic;}
.arduino .es0 {color: #000099; font-weight: bold;}
.arduino .es1 {color: #000099; font-weight: bold;}
.arduino .es2 {color: #660099; font-weight: bold;}
.arduino .es3 {color: #660099; font-weight: bold;}
.arduino .es4 {color: #660099; font-weight: bold;}
.arduino .es5 {color: #006699; font-weight: bold;}
.arduino .br0 {color: #000000;}
.arduino .sy0 {color: #000000;}
.arduino .st0 {color: #0066CC;}
.arduino .nu0 {color: #000000;}
.arduino .nu6 {color: #208080;}
.arduino .nu8 {color: #208080;}
.arduino .nu12 {color: #208080;}
.arduino .nu16 {color:#800080;}
.arduino .nu17 {color:#800080;}
.arduino .nu18 {color:#800080;}
.arduino .nu19 {color:#800080;}
.arduino .me1 {color: #ff1493;}
.arduino .me2 {color: #ff1493;}
.arduino span.xtra { display:block; }
.sourceblocklink {
text-align: right;
font-size: smaller;
}
.sourceblocktext {
padding: 0.5em;
color: #000000;
background-color: #ffffff;
}
.sourceblocktext div {
font-family: monospace;
font-size: small;
line-height: 1;
height: 1%;
}
.sourceblocktext div.head,
.sourceblocktext div.foot {
font: italic medium serif;
padding: 0.5em;
}
--></style> <meta name='robots' content='index,follow' />
<meta name="verify-v1" content="TtxFIEJAB6zdJ509wLxjnapQzKAMNm9u0Wj4ho6wxIY=" />
</head>
<body>
<div id="page">
<!--PageHeaderFmt-->
<div id="pageheader">
<div class="title"><a href='http://arduino.cc/en'>Arduino</a></div>
</div>
<!--/PageHeaderFmt-->
<!--PageLeftFmt-->
<div id="pagenav">
<div id="navbar">
<p><a class='wikilink' href='http://arduino.cc/en/Main/Buy'>Buy</a>
<a class='wikilink' href='http://arduino.cc/en/Main/Software'>Download</a>
<a class='wikilink' href='Guide_index.html'>Getting Started</a>
<a class='wikilink' href='http://arduino.cc/en/Tutorial/HomePage'>Learning</a>
<a class='wikilink' href='index.html'>Reference</a>
<a class='wikilink' href='http://arduino.cc/en/Main/Hardware'>Hardware</a>
<a class='wikilink' href='FAQ.html'>FAQ</a>
</p>
<p class='vspace'></p>
</div>
</div>
<!--/PageLeftFmt-->
<div id="pagetext">
<!--PageText-->
<div id='wikitext'>
<p><strong>Reference</strong> &nbsp; <a class='wikilink' href='index.html'>Language</a> | <a class='wikilink' href='Libraries.html'>Libraries</a> | <a class='wikilink' href='Comparison.html'>Comparison</a> | <a class='wikilink' href='Changes.html'>Changes</a>
</p>
<p class='vspace'></p><p><a class='wikilink' href='Ethernet.html'>Ethernet</a> : <em>UDP.remoteIP()</em>
</p>
<p class='vspace'></p><h4>Description</h4>
<p>Gets the IP address of the remote connection.
</p>
<p class='vspace'></p><p>This function must be called after <a class='wikilink' href='EthernetUDPParsePacket.html'>UDP.parsePacket()</a>.
</p>
<p class='vspace'></p><h4>Syntax</h4>
<p>UDP.remoteIP(); <br />
</p><h4>Parameters</h4>
<p>None
</p>
<p class='vspace'></p><h4>Returns</h4>
<p>4 bytes : the IP address of the remote connection
</p>
<p class='vspace'></p><h4>Example</h4>
<p>
<div class='sourceblock ' id='sourceblock1'>
<div class='sourceblocktext'><div class="arduino"><br />
<span class="co2">#include &lt;SPI.h&gt; &nbsp; &nbsp; &nbsp; &nbsp;</span><br />
<span class="co2">#include &lt;Ethernet.h&gt;</span><br />
<span class="co2">#include &lt;EthernetUdp.h&gt;</span><br />
<br />
<span class="co1">// Enter a MAC address and IP address for your controller below.</span><br />
<span class="co1">// The IP address will be dependent on your local network:</span><br />
<span class="kw1">byte</span> mac<span class="br0">&#91;</span><span class="br0">&#93;</span> <span class="sy0">=</span> <span class="br0">&#123;</span> &nbsp;<br />
&nbsp; <span class="nu12">0xDE</span><span class="sy0">,</span> <span class="nu12">0xAD</span><span class="sy0">,</span> <span class="nu12">0xBE</span><span class="sy0">,</span> <span class="nu12">0xEF</span><span class="sy0">,</span> <span class="nu12">0xFE</span><span class="sy0">,</span> <span class="nu12">0xED</span> <span class="br0">&#125;</span><span class="sy0">;</span><br />
IPAddress ip<span class="br0">&#40;</span><span class="nu0">192</span><span class="sy0">,</span> <span class="nu0">168</span><span class="sy0">,</span> <span class="nu0">1</span><span class="sy0">,</span> <span class="nu0">177</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
<br />
<span class="kw1">unsigned</span> <span class="kw1">int</span> localPort <span class="sy0">=</span> <span class="nu0">8888</span><span class="sy0">;</span> &nbsp; &nbsp; &nbsp;<span class="co1">// local port to listen on</span><br />
<br />
<span class="co1">// An EthernetUDP instance to let us send and receive packets over UDP</span><br />
EthernetUDP Udp<span class="sy0">;</span><br />
<br />
<span class="kw1">void</span> <span class="kw3">setup</span><span class="br0">&#40;</span><span class="br0">&#41;</span> <span class="br0">&#123;</span><br />
&nbsp; <span class="co1">// start the Ethernet and UDP:</span><br />
&nbsp; Ethernet.<span class="kw1">begin</span><span class="br0">&#40;</span>mac<span class="sy0">,</span>ip<span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; Udp.<span class="kw1">begin</span><span class="br0">&#40;</span>localPort<span class="br0">&#41;</span><span class="sy0">;</span><br />
<span class="br0">&#125;</span><br />
<br />
<span class="kw1">void</span> <span class="kw3">loop</span><span class="br0">&#40;</span><span class="br0">&#41;</span> <span class="br0">&#123;</span><br />
<br />
&nbsp; <span class="kw1">int</span> packetSize <span class="sy0">=</span> Udp.<span class="me1">parsePacket</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; <span class="kw1">if</span><span class="br0">&#40;</span>packetSize<span class="br0">&#41;</span><br />
&nbsp; <span class="br0">&#123;</span><br />
&nbsp; &nbsp; <span class="kw1">Serial</span>.<span class="kw1">print</span><span class="br0">&#40;</span><span class="st0">&quot;Received packet of size &quot;</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; <span class="kw1">Serial</span>.<span class="kw1">println</span><span class="br0">&#40;</span>packetSize<span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; <span class="kw1">Serial</span>.<span class="kw1">print</span><span class="br0">&#40;</span><span class="st0">&quot;From IP : &quot;</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
<br />
&nbsp; &nbsp; IPAddress remote <span class="sy0">=</span> Udp.<span class="me1">remoteIP</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; <span class="co1">//print out the remote connection's IP address</span><br />
&nbsp; &nbsp; <span class="kw1">Serial</span>.<span class="kw1">print</span><span class="br0">&#40;</span>remote<span class="br0">&#41;</span><span class="sy0">;</span><br />
<br />
&nbsp; &nbsp; <span class="kw1">Serial</span>.<span class="kw1">print</span><span class="br0">&#40;</span><span class="st0">&quot; on port : &quot;</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; <span class="co1">//print out the remote connection's port</span><br />
&nbsp; &nbsp; <span class="kw1">Serial</span>.<span class="kw1">println</span><span class="br0">&#40;</span>Udp.<span class="me1">remotePort</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; <span class="br0">&#125;</span><br />
<br />
<span class="br0">&#125;</span><br />
<br />
&nbsp;</div></div>
<div class='sourceblocklink'><a href='#' type='text/plain'>[Get Code]</a></div>
</div>
<a class='wikilink' href='index.html'>Reference Home</a>
</p>
<p class='vspace'></p><p><em>Corrections, suggestions, and new documentation should be posted to the <a class='urllink' href='http://arduino.cc/forum/index.php/board,23.0.html' rel='nofollow'>Forum</a>.</em>
</p>
<p class='vspace'></p><p>The text of the Arduino reference is licensed under a
<a class='urllink' href='http://creativecommons.org/licenses/by-sa/3.0/' rel='nofollow'>Creative Commons Attribution-ShareAlike 3.0 License</a>. Code samples in the reference are released into the public domain.
</p>
</div>
</div>
<!--PageFooterFmt-->
<div id="pagefooter">
&copy;Arduino |
<a href='#'>Edit Page</a> | <a href='#'>Page History</a> | <a href='#' target='_blank'>Printable View</a> | <a href='http://arduino.cc/en/Site/AllRecentChanges'>All Recent Site Changes</a>
</div>
<!--/PageFooterFmt-->
</div>
</body>
</html>

View File

@@ -0,0 +1,215 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>Arduino Reference - EthernetUDPRemotePort </title>
<link rel="shortcut icon" type="image/x-icon" href="http://arduino.cc/en/favicon.png">
<link rel='stylesheet' href='arduinoWideRender.css'
type='text/css' />
<!--HeaderText--><style type='text/css'><!--
ul, ol, pre, dl, p { margin-top:0px; margin-bottom:0px; }
code { white-space: nowrap; }
.vspace { margin-top:1.33em; }
.indent { margin-left:40px; }
.outdent { margin-left:40px; text-indent:-40px; }
a.createlinktext { text-decoration:none; border-bottom:1px dotted gray; }
a.createlink { text-decoration:none; position:relative; top:-0.5em;
font-weight:bold; font-size:smaller; border-bottom:none; }
img { border:0px; }
.editconflict { color:green;
font-style:italic; margin-top:1.33em; margin-bottom:1.33em; }
table.markup { border: 2px dotted #ccf; width:90%; }
td.markup1, td.markup2 { padding-left:10px; padding-right:10px; }
td.markup1 { border-bottom: 1px solid #ccf; }
div.faq { margin-left:2em; }
div.faq p.question { margin: 1em 0 0.75em -2em; font-weight:bold; }
div.faq hr { margin-left: -2em; }
.frame
{ border:1px solid #cccccc; padding:4px; background-color:#f9f9f9; }
.lfloat { float:left; margin-right:0.5em; }
.rfloat { float:right; margin-left:0.5em; }
a.varlink { text-decoration:none; }
/**
* GeSHi (C) 2004 - 2007 Nigel McNie, 2007 - 2008 Benny Baumann
* (http://qbnz.com/highlighter/ and http://geshi.org/)
*/
.arduino {font-family:monospace;}
.arduino .imp {font-weight: bold; color: red;}
.arduino .kw1 {color: #CC6600;}
.arduino .kw2 {color: #006699;}
.arduino .kw3 {color: #CC6600; font-weight: bold;}
.arduino .co1 {color: #7E7E7E; font-style: italic;}
.arduino .co2 {color: #7E7E7E;}
.arduino .coMULTI {color: #7E7E7E; font-style: italic;}
.arduino .es0 {color: #000099; font-weight: bold;}
.arduino .es1 {color: #000099; font-weight: bold;}
.arduino .es2 {color: #660099; font-weight: bold;}
.arduino .es3 {color: #660099; font-weight: bold;}
.arduino .es4 {color: #660099; font-weight: bold;}
.arduino .es5 {color: #006699; font-weight: bold;}
.arduino .br0 {color: #000000;}
.arduino .sy0 {color: #000000;}
.arduino .st0 {color: #0066CC;}
.arduino .nu0 {color: #000000;}
.arduino .nu6 {color: #208080;}
.arduino .nu8 {color: #208080;}
.arduino .nu12 {color: #208080;}
.arduino .nu16 {color:#800080;}
.arduino .nu17 {color:#800080;}
.arduino .nu18 {color:#800080;}
.arduino .nu19 {color:#800080;}
.arduino .me1 {color: #ff1493;}
.arduino .me2 {color: #ff1493;}
.arduino span.xtra { display:block; }
.sourceblocklink {
text-align: right;
font-size: smaller;
}
.sourceblocktext {
padding: 0.5em;
color: #000000;
background-color: #ffffff;
}
.sourceblocktext div {
font-family: monospace;
font-size: small;
line-height: 1;
height: 1%;
}
.sourceblocktext div.head,
.sourceblocktext div.foot {
font: italic medium serif;
padding: 0.5em;
}
--></style> <meta name='robots' content='index,follow' />
<meta name="verify-v1" content="TtxFIEJAB6zdJ509wLxjnapQzKAMNm9u0Wj4ho6wxIY=" />
</head>
<body>
<div id="page">
<!--PageHeaderFmt-->
<div id="pageheader">
<div class="title"><a href='http://arduino.cc/en'>Arduino</a></div>
</div>
<!--/PageHeaderFmt-->
<!--PageLeftFmt-->
<div id="pagenav">
<div id="navbar">
<p><a class='wikilink' href='http://arduino.cc/en/Main/Buy'>Buy</a>
<a class='wikilink' href='http://arduino.cc/en/Main/Software'>Download</a>
<a class='wikilink' href='Guide_index.html'>Getting Started</a>
<a class='wikilink' href='http://arduino.cc/en/Tutorial/HomePage'>Learning</a>
<a class='wikilink' href='index.html'>Reference</a>
<a class='wikilink' href='http://arduino.cc/en/Main/Hardware'>Hardware</a>
<a class='wikilink' href='FAQ.html'>FAQ</a>
</p>
<p class='vspace'></p>
</div>
</div>
<!--/PageLeftFmt-->
<div id="pagetext">
<!--PageText-->
<div id='wikitext'>
<p><strong>Reference</strong> &nbsp; <a class='wikilink' href='index.html'>Language</a> | <a class='wikilink' href='Libraries.html'>Libraries</a> | <a class='wikilink' href='Comparison.html'>Comparison</a> | <a class='wikilink' href='Changes.html'>Changes</a>
</p>
<p class='vspace'></p><p><a class='wikilink' href='Ethernet.html'>Ethernet</a> : <em>UDP.remotePort()</em>
</p>
<p class='vspace'></p><h4>Description</h4>
<p>Gets the port of the remote UDP connection.
</p>
<p class='vspace'></p><p>This function must be called after <a class='wikilink' href='EthernetUDPParsePacket.html'>UDP.parsePacket()</a>.
</p>
<p class='vspace'></p><h4>Syntax</h4>
<p>UDP.remotePort(); <br />
</p><h4>Parameters</h4>
<p>None
</p>
<p class='vspace'></p><h4>Returns</h4>
<p>int : the port of the UDP connection to a remote host
</p>
<p class='vspace'></p><h4>Example</h4>
<p>
<div class='sourceblock ' id='sourceblock1'>
<div class='sourceblocktext'><div class="arduino"><span class="co2">#include &lt;SPI.h&gt; &nbsp; &nbsp; &nbsp; &nbsp;</span><br />
<span class="co2">#include &lt;Ethernet.h&gt;</span><br />
<span class="co2">#include &lt;EthernetUdp.h&gt;</span><br />
<br />
<span class="co1">// Enter a MAC address and IP address for your controller below.</span><br />
<span class="co1">// The IP address will be dependent on your local network:</span><br />
<span class="kw1">byte</span> mac<span class="br0">&#91;</span><span class="br0">&#93;</span> <span class="sy0">=</span> <span class="br0">&#123;</span> &nbsp;<br />
&nbsp; <span class="nu12">0xDE</span><span class="sy0">,</span> <span class="nu12">0xAD</span><span class="sy0">,</span> <span class="nu12">0xBE</span><span class="sy0">,</span> <span class="nu12">0xEF</span><span class="sy0">,</span> <span class="nu12">0xFE</span><span class="sy0">,</span> <span class="nu12">0xED</span> <span class="br0">&#125;</span><span class="sy0">;</span><br />
IPAddress ip<span class="br0">&#40;</span><span class="nu0">192</span><span class="sy0">,</span> <span class="nu0">168</span><span class="sy0">,</span> <span class="nu0">1</span><span class="sy0">,</span> <span class="nu0">177</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
<br />
<span class="kw1">unsigned</span> <span class="kw1">int</span> localPort <span class="sy0">=</span> <span class="nu0">8888</span><span class="sy0">;</span> &nbsp; &nbsp; &nbsp;<span class="co1">// local port to listen on</span><br />
<br />
<span class="co1">// An EthernetUDP instance to let us send and receive packets over UDP</span><br />
EthernetUDP Udp<span class="sy0">;</span><br />
<br />
<span class="kw1">char</span> packetBuffer<span class="br0">&#91;</span>UDP_TX_PACKET_MAX_SIZE<span class="br0">&#93;</span><span class="sy0">;</span> <span class="co1">//buffer to hold incoming packet,</span><br />
<br />
<span class="kw1">void</span> <span class="kw3">setup</span><span class="br0">&#40;</span><span class="br0">&#41;</span> <span class="br0">&#123;</span><br />
&nbsp; <span class="co1">// start the Ethernet and UDP:</span><br />
&nbsp; Ethernet.<span class="kw1">begin</span><span class="br0">&#40;</span>mac<span class="sy0">,</span>ip<span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; Udp.<span class="kw1">begin</span><span class="br0">&#40;</span>localPort<span class="br0">&#41;</span><span class="sy0">;</span><br />
<br />
<span class="br0">&#125;</span><br />
<br />
<span class="kw1">void</span> <span class="kw3">loop</span><span class="br0">&#40;</span><span class="br0">&#41;</span> <span class="br0">&#123;</span><br />
<br />
&nbsp; <span class="kw1">int</span> packetSize <span class="sy0">=</span> Udp.<span class="me1">parsePacket</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; <span class="kw1">if</span><span class="br0">&#40;</span>packetSize<span class="br0">&#41;</span><br />
&nbsp; <span class="br0">&#123;</span><br />
&nbsp; &nbsp; <span class="kw1">Serial</span>.<span class="kw1">print</span><span class="br0">&#40;</span><span class="st0">&quot;Received packet of size &quot;</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; <span class="kw1">Serial</span>.<span class="kw1">println</span><span class="br0">&#40;</span>packetSize<span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; <span class="kw1">Serial</span>.<span class="kw1">print</span><span class="br0">&#40;</span><span class="st0">&quot;From &quot;</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; IPAddress remote <span class="sy0">=</span> Udp.<span class="me1">remoteIP</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; <span class="kw1">for</span> <span class="br0">&#40;</span><span class="kw1">int</span> i <span class="sy0">=</span><span class="nu0">0</span><span class="sy0">;</span> i <span class="sy0">&lt;</span> <span class="nu0">4</span><span class="sy0">;</span> i<span class="sy0">++</span><span class="br0">&#41;</span><br />
&nbsp; &nbsp; <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; <span class="kw1">Serial</span>.<span class="kw1">print</span><span class="br0">&#40;</span>remote<span class="br0">&#91;</span>i<span class="br0">&#93;</span><span class="sy0">,</span> <span class="kw2">DEC</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; &nbsp; <span class="kw1">if</span> <span class="br0">&#40;</span>i <span class="sy0">&lt;</span> <span class="nu0">3</span><span class="br0">&#41;</span><br />
&nbsp; &nbsp; &nbsp; <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">Serial</span>.<span class="kw1">print</span><span class="br0">&#40;</span><span class="st0">&quot;.&quot;</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span><br />
&nbsp; &nbsp; <span class="br0">&#125;</span><br />
&nbsp; &nbsp; <span class="kw1">Serial</span>.<span class="kw1">print</span><span class="br0">&#40;</span><span class="st0">&quot;, port &quot;</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; <span class="kw1">Serial</span>.<span class="kw1">println</span><span class="br0">&#40;</span>Udp.<span class="me1">remotePort</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
<br />
&nbsp; &nbsp; <span class="co1">// read the packet into packetBufffer</span><br />
&nbsp; &nbsp; Udp.<span class="kw1">read</span><span class="br0">&#40;</span>packetBuffer<span class="sy0">,</span>UDP_TX_PACKET_MAX_SIZE<span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; <span class="kw1">Serial</span>.<span class="kw1">println</span><span class="br0">&#40;</span><span class="st0">&quot;Contents:&quot;</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; <span class="kw1">Serial</span>.<span class="kw1">println</span><span class="br0">&#40;</span>packetBuffer<span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp;<span class="br0">&#125;</span><br />
<span class="br0">&#125;</span><br />
&nbsp;</div></div>
<div class='sourceblocklink'><a href='#' type='text/plain'>[Get Code]</a></div>
</div>
<a class='wikilink' href='index.html'>Reference Home</a>
</p>
<p class='vspace'></p><p><em>Corrections, suggestions, and new documentation should be posted to the <a class='urllink' href='http://arduino.cc/forum/index.php/board,23.0.html' rel='nofollow'>Forum</a>.</em>
</p>
<p class='vspace'></p><p>The text of the Arduino reference is licensed under a
<a class='urllink' href='http://creativecommons.org/licenses/by-sa/3.0/' rel='nofollow'>Creative Commons Attribution-ShareAlike 3.0 License</a>. Code samples in the reference are released into the public domain.
</p>
</div>
</div>
<!--PageFooterFmt-->
<div id="pagefooter">
&copy;Arduino |
<a href='#'>Edit Page</a> | <a href='#'>Page History</a> | <a href='#' target='_blank'>Printable View</a> | <a href='http://arduino.cc/en/Site/AllRecentChanges'>All Recent Site Changes</a>
</div>
<!--/PageFooterFmt-->
</div>
</body>
</html>

View File

@@ -0,0 +1,188 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>Arduino Reference - EthernetUDPWrite </title>
<link rel="shortcut icon" type="image/x-icon" href="http://arduino.cc/en/favicon.png">
<link rel='stylesheet' href='arduinoWideRender.css'
type='text/css' />
<!--HeaderText--><style type='text/css'><!--
ul, ol, pre, dl, p { margin-top:0px; margin-bottom:0px; }
code { white-space: nowrap; }
.vspace { margin-top:1.33em; }
.indent { margin-left:40px; }
.outdent { margin-left:40px; text-indent:-40px; }
a.createlinktext { text-decoration:none; border-bottom:1px dotted gray; }
a.createlink { text-decoration:none; position:relative; top:-0.5em;
font-weight:bold; font-size:smaller; border-bottom:none; }
img { border:0px; }
.editconflict { color:green;
font-style:italic; margin-top:1.33em; margin-bottom:1.33em; }
table.markup { border: 2px dotted #ccf; width:90%; }
td.markup1, td.markup2 { padding-left:10px; padding-right:10px; }
td.markup1 { border-bottom: 1px solid #ccf; }
div.faq { margin-left:2em; }
div.faq p.question { margin: 1em 0 0.75em -2em; font-weight:bold; }
div.faq hr { margin-left: -2em; }
.frame
{ border:1px solid #cccccc; padding:4px; background-color:#f9f9f9; }
.lfloat { float:left; margin-right:0.5em; }
.rfloat { float:right; margin-left:0.5em; }
a.varlink { text-decoration:none; }
/**
* GeSHi (C) 2004 - 2007 Nigel McNie, 2007 - 2008 Benny Baumann
* (http://qbnz.com/highlighter/ and http://geshi.org/)
*/
.arduino {font-family:monospace;}
.arduino .imp {font-weight: bold; color: red;}
.arduino .kw1 {color: #CC6600;}
.arduino .kw2 {color: #006699;}
.arduino .kw3 {color: #CC6600; font-weight: bold;}
.arduino .co1 {color: #7E7E7E; font-style: italic;}
.arduino .co2 {color: #7E7E7E;}
.arduino .coMULTI {color: #7E7E7E; font-style: italic;}
.arduino .es0 {color: #000099; font-weight: bold;}
.arduino .es1 {color: #000099; font-weight: bold;}
.arduino .es2 {color: #660099; font-weight: bold;}
.arduino .es3 {color: #660099; font-weight: bold;}
.arduino .es4 {color: #660099; font-weight: bold;}
.arduino .es5 {color: #006699; font-weight: bold;}
.arduino .br0 {color: #000000;}
.arduino .sy0 {color: #000000;}
.arduino .st0 {color: #0066CC;}
.arduino .nu0 {color: #000000;}
.arduino .nu6 {color: #208080;}
.arduino .nu8 {color: #208080;}
.arduino .nu12 {color: #208080;}
.arduino .nu16 {color:#800080;}
.arduino .nu17 {color:#800080;}
.arduino .nu18 {color:#800080;}
.arduino .nu19 {color:#800080;}
.arduino .me1 {color: #ff1493;}
.arduino .me2 {color: #ff1493;}
.arduino span.xtra { display:block; }
.sourceblocklink {
text-align: right;
font-size: smaller;
}
.sourceblocktext {
padding: 0.5em;
color: #000000;
background-color: #ffffff;
}
.sourceblocktext div {
font-family: monospace;
font-size: small;
line-height: 1;
height: 1%;
}
.sourceblocktext div.head,
.sourceblocktext div.foot {
font: italic medium serif;
padding: 0.5em;
}
--></style> <meta name='robots' content='index,follow' />
<meta name="verify-v1" content="TtxFIEJAB6zdJ509wLxjnapQzKAMNm9u0Wj4ho6wxIY=" />
</head>
<body>
<div id="page">
<!--PageHeaderFmt-->
<div id="pageheader">
<div class="title"><a href='http://arduino.cc/en'>Arduino</a></div>
</div>
<!--/PageHeaderFmt-->
<!--PageLeftFmt-->
<div id="pagenav">
<div id="navbar">
<p><a class='wikilink' href='http://arduino.cc/en/Main/Buy'>Buy</a>
<a class='wikilink' href='http://arduino.cc/en/Main/Software'>Download</a>
<a class='wikilink' href='Guide_index.html'>Getting Started</a>
<a class='wikilink' href='http://arduino.cc/en/Tutorial/HomePage'>Learning</a>
<a class='wikilink' href='index.html'>Reference</a>
<a class='wikilink' href='http://arduino.cc/en/Main/Hardware'>Hardware</a>
<a class='wikilink' href='FAQ.html'>FAQ</a>
</p>
<p class='vspace'></p>
</div>
</div>
<!--/PageLeftFmt-->
<div id="pagetext">
<!--PageText-->
<div id='wikitext'>
<p><strong>Reference</strong> &nbsp; <a class='wikilink' href='index.html'>Language</a> | <a class='wikilink' href='Libraries.html'>Libraries</a> | <a class='wikilink' href='Comparison.html'>Comparison</a> | <a class='wikilink' href='Changes.html'>Changes</a>
</p>
<p class='vspace'></p><p><a class='wikilink' href='Ethernet.html'>Ethernet</a> : <em>UDP.write()</em>
</p>
<p class='vspace'></p><h4>Description</h4>
<p>Writes UDP data to the remote connection. Must be wrapped between <a class='wikilink' href='EthernetUDPBeginPacket.html'>beginPacket</a>() and <a class='wikilink' href='EthernetUDPEndPacket.html'>endPacket</a>(). beginPacket() initializes the packet of data, it is not sent until endPacket() is called.
</p>
<p class='vspace'></p><h4>Syntax</h4>
<p>UDP.write(message); <br />
</p><h4>Parameters</h4>
<p><strong>message</strong>: the outgoing message (char)<br />
</p><h4>Returns</h4>
<p>byte : returns the number of characters sent. This does not have to be read
</p>
<p class='vspace'></p><h4>Example</h4>
<pre>
<div class='sourceblock ' id='sourceblock1'>
<div class='sourceblocktext'><div class="arduino"><span class="co2">#include &lt;SPI.h&gt; &nbsp; &nbsp; &nbsp; &nbsp;</span><br />
<span class="co2">#include &lt;Ethernet.h&gt;</span><br />
<span class="co2">#include &lt;EthernetUdp.h&gt;</span><br />
<br />
<span class="co1">// Enter a MAC address and IP address for your controller below.</span><br />
<span class="co1">// The IP address will be dependent on your local network:</span><br />
<span class="kw1">byte</span> mac<span class="br0">&#91;</span><span class="br0">&#93;</span> <span class="sy0">=</span> <span class="br0">&#123;</span> <span class="nu12">0xDE</span><span class="sy0">,</span> <span class="nu12">0xAD</span><span class="sy0">,</span> <span class="nu12">0xBE</span><span class="sy0">,</span> <span class="nu12">0xEF</span><span class="sy0">,</span> <span class="nu12">0xFE</span><span class="sy0">,</span> <span class="nu12">0xED</span> <span class="br0">&#125;</span><span class="sy0">;</span><br />
IPAddress ip<span class="br0">&#40;</span><span class="nu0">192</span><span class="sy0">,</span> <span class="nu0">168</span><span class="sy0">,</span> <span class="nu0">1</span><span class="sy0">,</span> <span class="nu0">177</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
<br />
<span class="kw1">unsigned</span> <span class="kw1">int</span> localPort <span class="sy0">=</span> <span class="nu0">8888</span><span class="sy0">;</span> &nbsp; &nbsp; &nbsp;<span class="co1">// local port to listen on</span><br />
<br />
<span class="co1">// An EthernetUDP instance to let us send and receive packets over UDP</span><br />
EthernetUDP Udp<span class="sy0">;</span><br />
<br />
<span class="kw1">void</span> <span class="kw3">setup</span><span class="br0">&#40;</span><span class="br0">&#41;</span> <span class="br0">&#123;</span><br />
&nbsp; <span class="co1">// start the Ethernet and UDP:</span><br />
&nbsp; Ethernet.<span class="kw1">begin</span><span class="br0">&#40;</span>mac<span class="sy0">,</span>ip<span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; Udp.<span class="kw1">begin</span><span class="br0">&#40;</span>localPort<span class="br0">&#41;</span><span class="sy0">;</span><br />
<span class="br0">&#125;</span><br />
<br />
<span class="kw1">void</span> <span class="kw3">loop</span><span class="br0">&#40;</span><span class="br0">&#41;</span> <span class="br0">&#123;</span><br />
&nbsp; Udp.<span class="me1">beginPacket</span><span class="br0">&#40;</span>Udp.<span class="me1">remoteIP</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">,</span> Udp.<span class="me1">remotePort</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; Udp.<span class="kw1">write</span><span class="br0">&#40;</span><span class="st0">&quot;hello&quot;</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; Udp.<span class="me1">endPacket</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
<span class="br0">&#125;</span></div></div>
<div class='sourceblocklink'><a href='#' type='text/plain'>[Get Code]</a></div>
</div>
</pre><p><a class='wikilink' href='index.html'>Reference Home</a>
</p>
<p class='vspace'></p><p><em>Corrections, suggestions, and new documentation should be posted to the <a class='urllink' href='http://arduino.cc/forum/index.php/board,23.0.html' rel='nofollow'>Forum</a>.</em>
</p>
<p class='vspace'></p><p>The text of the Arduino reference is licensed under a
<a class='urllink' href='http://creativecommons.org/licenses/by-sa/3.0/' rel='nofollow'>Creative Commons Attribution-ShareAlike 3.0 License</a>. Code samples in the reference are released into the public domain.
</p>
</div>
</div>
<!--PageFooterFmt-->
<div id="pagefooter">
&copy;Arduino |
<a href='#'>Edit Page</a> | <a href='#'>Page History</a> | <a href='#' target='_blank'>Printable View</a> | <a href='http://arduino.cc/en/Site/AllRecentChanges'>All Recent Site Changes</a>
</div>
<!--/PageFooterFmt-->
</div>
</body>
</html>

View File

@@ -0,0 +1,137 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>Arduino Reference - FAQ </title>
<link rel="shortcut icon" type="image/x-icon" href="http://arduino.cc/en/favicon.png">
<link rel='stylesheet' href='arduinoWideRender.css'
type='text/css' />
<!--HeaderText--><style type='text/css'><!--
ul, ol, pre, dl, p { margin-top:0px; margin-bottom:0px; }
code { white-space: nowrap; }
.vspace { margin-top:1.33em; }
.indent { margin-left:40px; }
.outdent { margin-left:40px; text-indent:-40px; }
a.createlinktext { text-decoration:none; border-bottom:1px dotted gray; }
a.createlink { text-decoration:none; position:relative; top:-0.5em;
font-weight:bold; font-size:smaller; border-bottom:none; }
img { border:0px; }
.editconflict { color:green;
font-style:italic; margin-top:1.33em; margin-bottom:1.33em; }
table.markup { border: 2px dotted #ccf; width:90%; }
td.markup1, td.markup2 { padding-left:10px; padding-right:10px; }
td.markup1 { border-bottom: 1px solid #ccf; }
div.faq { margin-left:2em; }
div.faq p.question { margin: 1em 0 0.75em -2em; font-weight:bold; }
div.faq hr { margin-left: -2em; }
.frame
{ border:1px solid #cccccc; padding:4px; background-color:#f9f9f9; }
.lfloat { float:left; margin-right:0.5em; }
.rfloat { float:right; margin-left:0.5em; }
a.varlink { text-decoration:none; }
--></style> <meta name='robots' content='index,follow' />
<meta name="verify-v1" content="TtxFIEJAB6zdJ509wLxjnapQzKAMNm9u0Wj4ho6wxIY=" />
</head>
<body>
<div id="page">
<!--PageHeaderFmt-->
<div id="pageheader">
<div class="title"><a href='http://arduino.cc/en'>Arduino</a></div>
</div>
<!--/PageHeaderFmt-->
<!--PageLeftFmt-->
<div id="pagenav">
<div id="navbar">
<p><a class='wikilink' href='http://arduino.cc/en/Main/Buy'>Buy</a>
<a class='wikilink' href='http://arduino.cc/en/Main/Software'>Download</a>
<a class='wikilink' href='Guide_index.html'>Getting Started</a>
<a class='wikilink' href='http://arduino.cc/en/Tutorial/HomePage'>Learning</a>
<a class='wikilink' href='index.html'>Reference</a>
<a class='wikilink' href='http://arduino.cc/en/Main/Hardware'>Hardware</a>
<a class='selflink' href='FAQ.html'>FAQ</a>
</p>
<p class='vspace'></p>
</div>
</div>
<!--/PageLeftFmt-->
<div id="pagetext">
<!--PageText-->
<div id='wikitext'>
<h2>Frequently Asked Questions</h2>
<div class="question">What is an Arduino?
<p class='vspace'></p></div><div class="answer">Glad you asked, we have a great introduction page on Arduino, <a class='urllink' href='http://www.arduino.cc/en/Guide/Introduction' rel='nofollow'>click here to read it.</a>
<p class='vspace'></p></div><div class="question">What do you mean by open-source hardware?
<p class='vspace'></p></div><div class="answer">Open-source hardware shares much of the principles and approach of free and open-source software. In particular, we believe that people should be able to study our hardware to understand how it works, make changes to it, and share those changes. To facilitate this, we release all of the original design files (Eagle CAD) for the Arduino hardware. These files are licensed under a Creative Commons Attribution Share-Alike license, which allows for both personal and commercial derivative works, as long as they credit Arduino and release their designs under the same license.
<p>The Arduino software is also open-source. The source code for the Java environment is released under the GPL and the C/C++ microcontroller libraries are under the LGPL.
</p>
<p class='vspace'></p></div><div class="question">How can I get an Arduino board?
<p class='vspace'></p></div><div class="answer">You can buy an Arduino board from the <a class='urllink' href='http://store.arduino.cc/ww/' rel='nofollow'>official store</a> online or from one of the distributors listed on the <a class='wikilink' href='http://arduino.cc/en/Main/Buy'>buy</a> page. If you'd prefer to build your own, see the <a class='wikilink' href='http://arduino.cc/en/Main/ArduinoBoardSerialSingleSided3'>Arduino Single-Sided Serial board</a>, which can be easily etched and assembled.
<p class='vspace'></p></div><div class="question">Who makes Arduino boards?
<p class='vspace'></p></div><div class="answer">Most of the official Arduino boards are manufactured by <span class='wikiword'>SmartProjects</span> in Italy. The Arduino Pro, Pro Mini, and <span class='wikiword'>LilyPad</span> are manufactured by <span class='wikiword'>SparkFun</span> Electronics (a US company). The Arduino Nano is manufactured by Gravitech (also a US company).
<p class='vspace'></p></div><div class="question">Which are the official Arduino boards?
<p class='vspace'></p></div><div class="answer">The official Arduino boards are the ones listed on the <a class='wikilink' href='http://arduino.cc/en/Main/Hardware'>hardware page</a>: the Uno, Mega2560, Nano, Bluetooth (BT), <span class='wikiword'>LilyPad</span>, Mini, Pro, Pro Mini, and a few older models, along with the Ethernet, <span class='wikiword'>XBee</span>, motor, and prototyping shields. These are boards whose manufacturers work with the Arduino team to ensure a good user experience, compatibility with the Arduino software, and a quality product. In return for their status as official boards, the manufacturers pay a licensing fee to the Arduino team to support the further development of the project.
<p>In general, we try to restrict use of the name "Arduino" to the official boards. If you find a product under a different name but described as "Arduino compatible", its probably not an official board and doesnt fund continued work on the project.
</p>
<p class='vspace'></p></div><div class="question">I want to design my own board; what should I do?
<p class='vspace'></p></div><div class="answer">The reference designs for the Arduino boards are available from the <a class='wikilink' href='http://arduino.cc/en/Main/Hardware'>hardware</a> page. They're licensed under a Creative Commons Attribution Share-Alike license, so you are free to use and adapt them for your own needs without asking permission or paying a fee. If you're looking to make something of interest to the community, we'd encourage you to discuss your ideas on the <a class='urllink' href='http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?board=hwdev' rel='nofollow'>hardware development forum</a> so that potential users can offer suggestions.
<p class='vspace'></p><p><a name='naming' id='naming'></a>
</p></div><div class="question">What should I call my boards?
<p class='vspace'></p></div><div class="answer">If you're making your own board, come up with your own name! This will allow people identify you with your products and help you to build a brand. Be creative: try to suggest what people might use the board for, or emphasize the form factor, or just pick a random word that sounds cool. "Arduino" is a trademark of Arduino team and should not be used for unofficial variants. If you're interested in having your design included in the official Arduino product line, please see the <a class='wikilink' href='http://arduino.cc/en/Main/Policy'>So you want to make an Arduino</a> document and contact the Arduino team.
<p>While unofficial products should not have "Arduino" in their name, it's okay to describe your product in relation to the Arduino project and platform. Here are a few guidelines that explain which uses we consider reasonable.
Not okay:
</p><ul><li>Arduino Xxxxxx
</li><li>Xxxxxx Arduino
</li><li>Arduino Compatible Xxxxxx - use "Xxxxxx (Arduino-Compatible)" instead
</li></ul><p>Okay:
</p><ul><li>Xxxxxx for Arduino - products that work with official Arduino boards (e.g. shields or kits)
</li><li>Xxxxxx (Arduino-Compatible) - variations and clones which are software and hardware compatible
</li></ul><p>Note that while we don't attempt to restrict uses of the "duino" suffix, its use causes the Italians on the team to cringe (apparently it sounds terrible); you might want to avoid it. (It's also trademarked by a Hungarian company.)
</p>
<p class='vspace'></p></div><div class="question">Can I build a commercial product based on Arduino?
<p class='vspace'></p></div><div class="answer">Yes, with the following conditions:
<ul><li>Physically embedding an Arduino board inside a commercial product does not require you to disclose or open-source any information about its design.
</li><li>Deriving the design of a commercial product from the Eagle files for an Arduino board requires you to release the modified files under the same Creative Commons Attribution Share-Alike license. You may manufacture and sell the resulting product.
</li><li>Using the Arduino core and libraries for the firmware of a commercial product does not require you to release the source code for the firmware. The LGPL does, however, require you to make available object files that allow for the relinking of the firmware against updated versions of the Arduino core and libraries. Any modifications to the core and libraries must be released under the LGPL.
</li><li>The source code for the Arduino environment is covered by the GPL, which requires any modifications to be open-sourced under the same license. It does not prevent the sale of derivative software or its inclusion in commercial products.
</li></ul><p>In all cases, the exact requirements are determined by the applicable license. Additionally, see the previous question for information about the use of the name “Arduino”.
</p>
<p class='vspace'></p><p><a name='linux' id='linux'></a>
</p></div><div class="question">How can I run the Arduino IDE under Linux?
<p class='vspace'></p></div><div class="answer">See instructions <a class='urllink' href='http://www.arduino.cc/playground/Linux/Ubuntu' rel='nofollow'>for Ubuntu Linux</a>, <a class='urllink' href='http://www.arduino.cc/playground/Linux/Debian' rel='nofollow'>for Debian Linux</a>, <a class='urllink' href='http://www.arduino.cc/playground/Linux/Gentoo' rel='nofollow'>for Gentoo Linux</a>, <a class='urllink' href='http://www.arduino.cc/playground/Learning/Linux' rel='nofollow'>for Linux</a>, or <a class='urllink' href='http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1141345598' rel='nofollow'>for Linux on PPC</a>. This <a class='urllink' href='http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1129025529' rel='nofollow'>this forum thread</a> has more information. Or, you can <a class='urllink' href='http://www.arduino.cc/playground/Learning/CommandLine' rel='nofollow'>use Arduino from the command line</a>, and not have to install Java.
<p class='vspace'></p></div><div class="question">Can I program the Arduino board in C?
<p class='vspace'></p></div><div class="answer">In fact, you already are; the Arduino language is merely a set of C/C++ functions that can be called from your code. Your sketch undergoes minor changes (e.g. automatic generation of function prototypes) and then is passed directly to a C/C++ compiler (avr-g++). All standard C and C++ constructs <a class='urllink' href='http://www.nongnu.org/avr-libc/user-manual/FAQ.html#faq_cplusplus' rel='nofollow'>supported by avr-g++</a> should work in Arduino. For more details, see the page on the <a class='wikilink' href='http://arduino.cc/en/Hacking/BuildProcess'>Arduino build process</a>.
<p class='vspace'></p></div><div class="question">Can I use a different IDE to program the Arduino board?
<p class='vspace'></p></div><div class="answer">It is possible to compile programs for the Arduino using other build tools (e.g. Makefiles and/or AVR Studio). You'll need to configure these to link against the appropriate files in the Arduino core libraries. See the description of the Arduino <a class='urllink' href='http://code.google.com/p/arduino/wiki/BuildProcess' rel='nofollow'>build process</a>.
<p class='vspace'></p></div><div class="question">Can I use an Arduino board without the Arduino software?
<p class='vspace'></p></div><div class="answer">Sure. It's just an AVR development board, you can use straight AVR C or C++ (with avr-gcc and avrdude or AVR Studio) to program it.
<p class='vspace'></p></div><div class="question">Can I use the Arduino software with other AVR boards?
<p class='vspace'></p></div><div class="answer">Yes, although it may require some modifications to the Arduino core libraries. See the <a class='urllink' href='http://code.google.com/p/arduino/wiki/Porting' rel='nofollow'>porting page</a> in the Arduino Google Code project for details.
<p class='vspace'></p></div><div class="question">Where is the troubleshooting section?
</div><div class="answer">These questions have moved to the <a class='wikilink' href='Guide_Troubleshooting.html'>troubleshooting</a> section of the Arduino <a class='wikilink' href='Guide_index.html'>guide</a>.
<p class='vspace'></p></div><div class="question"> Do you have a Privacy Policy about my data as registered user
</div><div class="answer">Yes, check out our <a class='urllink' href='http://arduino.cc/en/Main/PrivacyPolicy' rel='nofollow'>Privacy Policy</a> page. There you will see how we handle visitor's information and our non-disclosure policies.
<p class='vspace'></p></div><div class="question">
</div><div class="answer">
</div>
</div>
</div>
<!--PageFooterFmt-->
<div id="pagefooter">
&copy;Arduino |
<a href='FAQ.html?action=edit'>Edit Page</a> | <a href='FAQ.html?action=diff'>Page History</a> | <a href='FAQ.html?action=print' target='_blank'>Printable View</a> | <a href='http://arduino.cc/en/Site/AllRecentChanges'>All Recent Site Changes</a>
</div>
<!--/PageFooterFmt-->
</div>
</body>
</html>

View File

@@ -0,0 +1,110 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>Arduino Reference - FileAvailable </title>
<link rel="shortcut icon" type="image/x-icon" href="http://arduino.cc/en/favicon.png">
<link rel='stylesheet' href='arduinoWideRender.css'
type='text/css' />
<!--HeaderText--><style type='text/css'><!--
ul, ol, pre, dl, p { margin-top:0px; margin-bottom:0px; }
code { white-space: nowrap; }
.vspace { margin-top:1.33em; }
.indent { margin-left:40px; }
.outdent { margin-left:40px; text-indent:-40px; }
a.createlinktext { text-decoration:none; border-bottom:1px dotted gray; }
a.createlink { text-decoration:none; position:relative; top:-0.5em;
font-weight:bold; font-size:smaller; border-bottom:none; }
img { border:0px; }
.editconflict { color:green;
font-style:italic; margin-top:1.33em; margin-bottom:1.33em; }
table.markup { border: 2px dotted #ccf; width:90%; }
td.markup1, td.markup2 { padding-left:10px; padding-right:10px; }
td.markup1 { border-bottom: 1px solid #ccf; }
div.faq { margin-left:2em; }
div.faq p.question { margin: 1em 0 0.75em -2em; font-weight:bold; }
div.faq hr { margin-left: -2em; }
.frame
{ border:1px solid #cccccc; padding:4px; background-color:#f9f9f9; }
.lfloat { float:left; margin-right:0.5em; }
.rfloat { float:right; margin-left:0.5em; }
a.varlink { text-decoration:none; }
--></style> <meta name='robots' content='index,follow' />
<meta name="verify-v1" content="TtxFIEJAB6zdJ509wLxjnapQzKAMNm9u0Wj4ho6wxIY=" />
</head>
<body>
<div id="page">
<!--PageHeaderFmt-->
<div id="pageheader">
<div class="title"><a href='http://arduino.cc/en'>Arduino</a></div>
</div>
<!--/PageHeaderFmt-->
<!--PageLeftFmt-->
<div id="pagenav">
<div id="navbar">
<p><a class='wikilink' href='http://arduino.cc/en/Main/Buy'>Buy</a>
<a class='wikilink' href='http://arduino.cc/en/Main/Software'>Download</a>
<a class='wikilink' href='Guide_index.html'>Getting Started</a>
<a class='wikilink' href='http://arduino.cc/en/Tutorial/HomePage'>Learning</a>
<a class='wikilink' href='index.html'>Reference</a>
<a class='wikilink' href='http://arduino.cc/en/Main/Hardware'>Hardware</a>
<a class='wikilink' href='FAQ.html'>FAQ</a>
</p>
<p class='vspace'></p>
</div>
</div>
<!--/PageLeftFmt-->
<div id="pagetext">
<!--PageText-->
<div id='wikitext'>
<p><strong>Reference</strong> &nbsp; <a class='wikilink' href='index.html'>Language</a> | <a class='wikilink' href='Libraries.html'>Libraries</a> | <a class='wikilink' href='Comparison.html'>Comparison</a> | <a class='wikilink' href='Changes.html'>Changes</a>
</p>
<p class='vspace'></p><p><a class='wikilink' href='SD.html'>SD</a> : <em>File</em> class
</p>
<p class='vspace'></p><h2>available()</h2>
<p>Check if there are any bytes available for reading from the file.
</p>
<p class='vspace'></p><p>available() inherits from the <a class='wikilink' href='Stream.html'>Stream</a> utility class.
</p>
<p class='vspace'></p><h4>Syntax</h4>
<p><em>file</em>.available()
</p>
<p class='vspace'></p><h4>Parameters</h4>
<p><em>file</em>: an instance of the File class (returned by <a class='wikilink' href='SDopen.html'>SD.open()</a>)
</p>
<p class='vspace'></p><h4>Returns</h4>
<p>the number of bytes available (<em>int</em>)
</p>
<p class='vspace'></p><h4>See Also</h4>
<ul><li><a class='wikilink' href='FileRead.html'>read()</a>
</li><li><a class='wikilink' href='FilePeek.html'>peek()</a>
</li><li><a class='wikilink' href='StreamAvailable.html'>Stream.available()</a>
</li></ul><p class='vspace'></p><p><a class='wikilink' href='index.html'>Reference Home</a>
</p>
<p class='vspace'></p><p><em>Corrections, suggestions, and new documentation should be posted to the <a class='urllink' href='http://arduino.cc/forum/index.php/board,23.0.html' rel='nofollow'>Forum</a>.</em>
</p>
<p class='vspace'></p><p>The text of the Arduino reference is licensed under a
<a class='urllink' href='http://creativecommons.org/licenses/by-sa/3.0/' rel='nofollow'>Creative Commons Attribution-ShareAlike 3.0 License</a>. Code samples in the reference are released into the public domain.
</p>
</div>
</div>
<!--PageFooterFmt-->
<div id="pagefooter">
&copy;Arduino |
<a href='#'>Edit Page</a> | <a href='#'>Page History</a> | <a href='#' target='_blank'>Printable View</a> | <a href='http://arduino.cc/en/Site/AllRecentChanges'>All Recent Site Changes</a>
</div>
<!--/PageFooterFmt-->
</div>
</body>
</html>

View File

@@ -0,0 +1,106 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>Arduino Reference - FileClose </title>
<link rel="shortcut icon" type="image/x-icon" href="http://arduino.cc/en/favicon.png">
<link rel='stylesheet' href='arduinoWideRender.css'
type='text/css' />
<!--HeaderText--><style type='text/css'><!--
ul, ol, pre, dl, p { margin-top:0px; margin-bottom:0px; }
code { white-space: nowrap; }
.vspace { margin-top:1.33em; }
.indent { margin-left:40px; }
.outdent { margin-left:40px; text-indent:-40px; }
a.createlinktext { text-decoration:none; border-bottom:1px dotted gray; }
a.createlink { text-decoration:none; position:relative; top:-0.5em;
font-weight:bold; font-size:smaller; border-bottom:none; }
img { border:0px; }
.editconflict { color:green;
font-style:italic; margin-top:1.33em; margin-bottom:1.33em; }
table.markup { border: 2px dotted #ccf; width:90%; }
td.markup1, td.markup2 { padding-left:10px; padding-right:10px; }
td.markup1 { border-bottom: 1px solid #ccf; }
div.faq { margin-left:2em; }
div.faq p.question { margin: 1em 0 0.75em -2em; font-weight:bold; }
div.faq hr { margin-left: -2em; }
.frame
{ border:1px solid #cccccc; padding:4px; background-color:#f9f9f9; }
.lfloat { float:left; margin-right:0.5em; }
.rfloat { float:right; margin-left:0.5em; }
a.varlink { text-decoration:none; }
--></style> <meta name='robots' content='index,follow' />
<meta name="verify-v1" content="TtxFIEJAB6zdJ509wLxjnapQzKAMNm9u0Wj4ho6wxIY=" />
</head>
<body>
<div id="page">
<!--PageHeaderFmt-->
<div id="pageheader">
<div class="title"><a href='http://arduino.cc/en'>Arduino</a></div>
</div>
<!--/PageHeaderFmt-->
<!--PageLeftFmt-->
<div id="pagenav">
<div id="navbar">
<p><a class='wikilink' href='http://arduino.cc/en/Main/Buy'>Buy</a>
<a class='wikilink' href='http://arduino.cc/en/Main/Software'>Download</a>
<a class='wikilink' href='Guide_index.html'>Getting Started</a>
<a class='wikilink' href='http://arduino.cc/en/Tutorial/HomePage'>Learning</a>
<a class='wikilink' href='index.html'>Reference</a>
<a class='wikilink' href='http://arduino.cc/en/Main/Hardware'>Hardware</a>
<a class='wikilink' href='FAQ.html'>FAQ</a>
</p>
<p class='vspace'></p>
</div>
</div>
<!--/PageLeftFmt-->
<div id="pagetext">
<!--PageText-->
<div id='wikitext'>
<p><strong>Reference</strong> &nbsp; <a class='wikilink' href='index.html'>Language</a> | <a class='wikilink' href='Libraries.html'>Libraries</a> | <a class='wikilink' href='Comparison.html'>Comparison</a> | <a class='wikilink' href='Changes.html'>Changes</a>
</p>
<p class='vspace'></p><p><a class='wikilink' href='SD.html'>SD</a> : <em>File</em> class
</p>
<p class='vspace'></p><h2>close()</h2>
<p>Close the file, and ensure that any data written to it is physically saved to the SD card. Because the SD library support only one open file at a time, you must close a file before opening another one.
</p>
<p class='vspace'></p><h4>Syntax</h4>
<p><em>file</em>.close()
</p>
<p class='vspace'></p><h4>Parameters</h4>
<p><em>file</em>: an instance of the File class (returned by <a class='wikilink' href='SDopen.html'>SD.open()</a>)
</p>
<p class='vspace'></p><h4>Returns</h4>
<p>none
</p>
<p class='vspace'></p><h4>See Also</h4>
<ul><li><a class='wikilink' href='SDopen.html'>SD: open()</a>
</li></ul><p><a class='wikilink' href='index.html'>Reference Home</a>
</p>
<p class='vspace'></p><p><em>Corrections, suggestions, and new documentation should be posted to the <a class='urllink' href='http://arduino.cc/forum/index.php/board,23.0.html' rel='nofollow'>Forum</a>.</em>
</p>
<p class='vspace'></p><p>The text of the Arduino reference is licensed under a
<a class='urllink' href='http://creativecommons.org/licenses/by-sa/3.0/' rel='nofollow'>Creative Commons Attribution-ShareAlike 3.0 License</a>. Code samples in the reference are released into the public domain.
</p>
</div>
</div>
<!--PageFooterFmt-->
<div id="pagefooter">
&copy;Arduino |
<a href='#'>Edit Page</a> | <a href='#'>Page History</a> | <a href='#' target='_blank'>Printable View</a> | <a href='http://arduino.cc/en/Site/AllRecentChanges'>All Recent Site Changes</a>
</div>
<!--/PageFooterFmt-->
</div>
</body>
</html>

View File

@@ -0,0 +1,109 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>Arduino Reference - FileFlush </title>
<link rel="shortcut icon" type="image/x-icon" href="http://arduino.cc/en/favicon.png">
<link rel='stylesheet' href='arduinoWideRender.css'
type='text/css' />
<!--HeaderText--><style type='text/css'><!--
ul, ol, pre, dl, p { margin-top:0px; margin-bottom:0px; }
code { white-space: nowrap; }
.vspace { margin-top:1.33em; }
.indent { margin-left:40px; }
.outdent { margin-left:40px; text-indent:-40px; }
a.createlinktext { text-decoration:none; border-bottom:1px dotted gray; }
a.createlink { text-decoration:none; position:relative; top:-0.5em;
font-weight:bold; font-size:smaller; border-bottom:none; }
img { border:0px; }
.editconflict { color:green;
font-style:italic; margin-top:1.33em; margin-bottom:1.33em; }
table.markup { border: 2px dotted #ccf; width:90%; }
td.markup1, td.markup2 { padding-left:10px; padding-right:10px; }
td.markup1 { border-bottom: 1px solid #ccf; }
div.faq { margin-left:2em; }
div.faq p.question { margin: 1em 0 0.75em -2em; font-weight:bold; }
div.faq hr { margin-left: -2em; }
.frame
{ border:1px solid #cccccc; padding:4px; background-color:#f9f9f9; }
.lfloat { float:left; margin-right:0.5em; }
.rfloat { float:right; margin-left:0.5em; }
a.varlink { text-decoration:none; }
--></style> <meta name='robots' content='index,follow' />
<meta name="verify-v1" content="TtxFIEJAB6zdJ509wLxjnapQzKAMNm9u0Wj4ho6wxIY=" />
</head>
<body>
<div id="page">
<!--PageHeaderFmt-->
<div id="pageheader">
<div class="title"><a href='http://arduino.cc/en'>Arduino</a></div>
</div>
<!--/PageHeaderFmt-->
<!--PageLeftFmt-->
<div id="pagenav">
<div id="navbar">
<p><a class='wikilink' href='http://arduino.cc/en/Main/Buy'>Buy</a>
<a class='wikilink' href='http://arduino.cc/en/Main/Software'>Download</a>
<a class='wikilink' href='Guide_index.html'>Getting Started</a>
<a class='wikilink' href='http://arduino.cc/en/Tutorial/HomePage'>Learning</a>
<a class='wikilink' href='index.html'>Reference</a>
<a class='wikilink' href='http://arduino.cc/en/Main/Hardware'>Hardware</a>
<a class='wikilink' href='FAQ.html'>FAQ</a>
</p>
<p class='vspace'></p>
</div>
</div>
<!--/PageLeftFmt-->
<div id="pagetext">
<!--PageText-->
<div id='wikitext'>
<p><strong>Reference</strong> &nbsp; <a class='wikilink' href='index.html'>Language</a> | <a class='wikilink' href='Libraries.html'>Libraries</a> | <a class='wikilink' href='Comparison.html'>Comparison</a> | <a class='wikilink' href='Changes.html'>Changes</a>
</p>
<p class='vspace'></p><p><a class='wikilink' href='SD.html'>SD</a> : <em>File</em> class
</p>
<p class='vspace'></p><h2>flush()</h2>
<p>Ensures that any bytes written to the file are physically saved to the SD card. This is done automatically when the file is closed.
</p>
<p class='vspace'></p><p>flush() inherits from the <a class='wikilink' href='Stream.html'>Stream</a> utility class.
</p>
<p class='vspace'></p><h4>Syntax</h4>
<p><em>file</em>.flush()
</p>
<p class='vspace'></p><h4>Parameters</h4>
<p><em>file</em>: an instance of the File class (returned by <a class='wikilink' href='SDopen.html'>SD.open()</a>)
</p>
<p class='vspace'></p><h4>Returns</h4>
<p>none
</p>
<p class='vspace'></p><h4>See Also</h4>
<ul><li><a class='wikilink' href='FileClose.html'>close()</a>
</li><li><a class='wikilink' href='StreamFlush.html'>Stream.flush()</a>
</li></ul><p class='vspace'></p><p><a class='wikilink' href='index.html'>Reference Home</a>
</p>
<p class='vspace'></p><p><em>Corrections, suggestions, and new documentation should be posted to the <a class='urllink' href='http://arduino.cc/forum/index.php/board,23.0.html' rel='nofollow'>Forum</a>.</em>
</p>
<p class='vspace'></p><p>The text of the Arduino reference is licensed under a
<a class='urllink' href='http://creativecommons.org/licenses/by-sa/3.0/' rel='nofollow'>Creative Commons Attribution-ShareAlike 3.0 License</a>. Code samples in the reference are released into the public domain.
</p>
</div>
</div>
<!--PageFooterFmt-->
<div id="pagefooter">
&copy;Arduino |
<a href='#'>Edit Page</a> | <a href='#'>Page History</a> | <a href='#' target='_blank'>Printable View</a> | <a href='http://arduino.cc/en/Site/AllRecentChanges'>All Recent Site Changes</a>
</div>
<!--/PageFooterFmt-->
</div>
</body>
</html>

View File

@@ -0,0 +1,213 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>Arduino Reference - FileIsDirectory </title>
<link rel="shortcut icon" type="image/x-icon" href="http://arduino.cc/en/favicon.png">
<link rel='stylesheet' href='arduinoWideRender.css'
type='text/css' />
<!--HeaderText--><style type='text/css'><!--
ul, ol, pre, dl, p { margin-top:0px; margin-bottom:0px; }
code { white-space: nowrap; }
.vspace { margin-top:1.33em; }
.indent { margin-left:40px; }
.outdent { margin-left:40px; text-indent:-40px; }
a.createlinktext { text-decoration:none; border-bottom:1px dotted gray; }
a.createlink { text-decoration:none; position:relative; top:-0.5em;
font-weight:bold; font-size:smaller; border-bottom:none; }
img { border:0px; }
.editconflict { color:green;
font-style:italic; margin-top:1.33em; margin-bottom:1.33em; }
table.markup { border: 2px dotted #ccf; width:90%; }
td.markup1, td.markup2 { padding-left:10px; padding-right:10px; }
td.markup1 { border-bottom: 1px solid #ccf; }
div.faq { margin-left:2em; }
div.faq p.question { margin: 1em 0 0.75em -2em; font-weight:bold; }
div.faq hr { margin-left: -2em; }
.frame
{ border:1px solid #cccccc; padding:4px; background-color:#f9f9f9; }
.lfloat { float:left; margin-right:0.5em; }
.rfloat { float:right; margin-left:0.5em; }
a.varlink { text-decoration:none; }
/**
* GeSHi (C) 2004 - 2007 Nigel McNie, 2007 - 2008 Benny Baumann
* (http://qbnz.com/highlighter/ and http://geshi.org/)
*/
.arduino {font-family:monospace;}
.arduino .imp {font-weight: bold; color: red;}
.arduino .kw1 {color: #CC6600;}
.arduino .kw2 {color: #006699;}
.arduino .kw3 {color: #CC6600; font-weight: bold;}
.arduino .co1 {color: #7E7E7E; font-style: italic;}
.arduino .co2 {color: #7E7E7E;}
.arduino .coMULTI {color: #7E7E7E; font-style: italic;}
.arduino .es0 {color: #000099; font-weight: bold;}
.arduino .es1 {color: #000099; font-weight: bold;}
.arduino .es2 {color: #660099; font-weight: bold;}
.arduino .es3 {color: #660099; font-weight: bold;}
.arduino .es4 {color: #660099; font-weight: bold;}
.arduino .es5 {color: #006699; font-weight: bold;}
.arduino .br0 {color: #000000;}
.arduino .sy0 {color: #000000;}
.arduino .st0 {color: #0066CC;}
.arduino .nu0 {color: #000000;}
.arduino .nu6 {color: #208080;}
.arduino .nu8 {color: #208080;}
.arduino .nu12 {color: #208080;}
.arduino .nu16 {color:#800080;}
.arduino .nu17 {color:#800080;}
.arduino .nu18 {color:#800080;}
.arduino .nu19 {color:#800080;}
.arduino .me1 {color: #ff1493;}
.arduino .me2 {color: #ff1493;}
.arduino span.xtra { display:block; }
.sourceblocklink {
text-align: right;
font-size: smaller;
}
.sourceblocktext {
padding: 0.5em;
color: #000000;
background-color: #ffffff;
}
.sourceblocktext div {
font-family: monospace;
font-size: small;
line-height: 1;
height: 1%;
}
.sourceblocktext div.head,
.sourceblocktext div.foot {
font: italic medium serif;
padding: 0.5em;
}
--></style> <meta name='robots' content='index,follow' />
<meta name="verify-v1" content="TtxFIEJAB6zdJ509wLxjnapQzKAMNm9u0Wj4ho6wxIY=" />
</head>
<body>
<div id="page">
<!--PageHeaderFmt-->
<div id="pageheader">
<div class="title"><a href='http://arduino.cc/en'>Arduino</a></div>
</div>
<!--/PageHeaderFmt-->
<!--PageLeftFmt-->
<div id="pagenav">
<div id="navbar">
<p><a class='wikilink' href='http://arduino.cc/en/Main/Buy'>Buy</a>
<a class='wikilink' href='http://arduino.cc/en/Main/Software'>Download</a>
<a class='wikilink' href='Guide_index.html'>Getting Started</a>
<a class='wikilink' href='http://arduino.cc/en/Tutorial/HomePage'>Learning</a>
<a class='wikilink' href='index.html'>Reference</a>
<a class='wikilink' href='http://arduino.cc/en/Main/Hardware'>Hardware</a>
<a class='wikilink' href='FAQ.html'>FAQ</a>
</p>
<p class='vspace'></p>
</div>
</div>
<!--/PageLeftFmt-->
<div id="pagetext">
<!--PageText-->
<div id='wikitext'>
<p><strong>Reference</strong> &nbsp; <a class='wikilink' href='index.html'>Language</a> | <a class='wikilink' href='Libraries.html'>Libraries</a> | <a class='wikilink' href='Comparison.html'>Comparison</a> | <a class='wikilink' href='Changes.html'>Changes</a>
</p>
<p class='vspace'></p><p><a class='wikilink' href='SD.html'>SD</a> : <em>File</em> class
</p>
<p class='vspace'></p><h2>isDirectory()</h2>
<p>Directories (or folders) are special kinds of files, this function reports if the current file is a directory or not.
</p>
<p class='vspace'></p><h4>Syntax</h4>
<p><em>file</em>.isDirectory()
</p>
<p class='vspace'></p><h4>Parameters</h4>
<p><em>file</em>: an instance of the File class (returned by file.<a class='wikilink' href='SDopen.html'>open()</a>
</p>
<p class='vspace'></p><h4>Returns</h4>
<p>boolean
</p>
<p class='vspace'></p><h4>Example</h4>
<p>
<div class='sourceblock ' id='sourceblock1'>
<div class='sourceblocktext'><div class="arduino"><span class="co2">#include &lt;SD.h&gt;</span><br />
<br />
File root<span class="sy0">;</span><br />
<br />
<span class="kw1">void</span> <span class="kw3">setup</span><span class="br0">&#40;</span><span class="br0">&#41;</span><br />
<span class="br0">&#123;</span><br />
&nbsp; <span class="kw1">Serial</span>.<span class="kw1">begin</span><span class="br0">&#40;</span><span class="nu0">9600</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; <span class="kw1">pinMode</span><span class="br0">&#40;</span><span class="nu0">10</span><span class="sy0">,</span> <span class="kw2">OUTPUT</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
<br />
&nbsp; SD.<span class="kw1">begin</span><span class="br0">&#40;</span><span class="nu0">10</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
<br />
&nbsp; root <span class="sy0">=</span> SD.<span class="me1">open</span><span class="br0">&#40;</span><span class="st0">&quot;/&quot;</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
<br />
&nbsp; printDirectory<span class="br0">&#40;</span>root<span class="sy0">,</span> <span class="nu0">0</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
<br />
&nbsp; <span class="kw1">Serial</span>.<span class="kw1">println</span><span class="br0">&#40;</span><span class="st0">&quot;done!&quot;</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
<span class="br0">&#125;</span><br />
<br />
<span class="kw1">void</span> <span class="kw3">loop</span><span class="br0">&#40;</span><span class="br0">&#41;</span><br />
<span class="br0">&#123;</span><br />
&nbsp; <span class="co1">// nothing happens after setup finishes.</span><br />
<span class="br0">&#125;</span><br />
<br />
<span class="kw1">void</span> printDirectory<span class="br0">&#40;</span>File dir<span class="sy0">,</span> <span class="kw1">int</span> numTabs<span class="br0">&#41;</span> <span class="br0">&#123;</span><br />
&nbsp; &nbsp;<span class="kw1">while</span><span class="br0">&#40;</span><span class="kw1">true</span><span class="br0">&#41;</span> <span class="br0">&#123;</span><br />
<br />
&nbsp; &nbsp; &nbsp;File entry <span class="sy0">=</span> &nbsp;dir.<span class="me1">openNextFile</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; &nbsp;<span class="kw1">if</span> <span class="br0">&#40;</span><span class="sy0">!</span> entry<span class="br0">&#41;</span> <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp;<span class="co1">// no more files</span><br />
&nbsp; &nbsp; &nbsp; &nbsp;<span class="co1">//Serial.println(&quot;**nomorefiles**&quot;);</span><br />
&nbsp; &nbsp; &nbsp; &nbsp;<span class="kw1">break</span><span class="sy0">;</span><br />
&nbsp; &nbsp; &nbsp;<span class="br0">&#125;</span><br />
&nbsp; &nbsp; &nbsp;<span class="kw1">for</span> <span class="br0">&#40;</span>uint8_t i<span class="sy0">=</span><span class="nu0">0</span><span class="sy0">;</span> i<span class="sy0">&lt;</span>numTabs<span class="sy0">;</span> i<span class="sy0">++</span><span class="br0">&#41;</span> <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp;<span class="kw1">Serial</span>.<span class="kw1">print</span><span class="br0">&#40;</span><span class="st0">'<span class="es1">\t</span>'</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; &nbsp;<span class="br0">&#125;</span><br />
&nbsp; &nbsp; &nbsp;<span class="kw1">Serial</span>.<span class="kw1">print</span><span class="br0">&#40;</span>entry.<span class="me1">name</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; &nbsp;<span class="kw1">if</span> <span class="br0">&#40;</span>entry.<span class="me1">isDirectory</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="br0">&#41;</span> <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp;<span class="kw1">Serial</span>.<span class="kw1">println</span><span class="br0">&#40;</span><span class="st0">&quot;/&quot;</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp;printDirectory<span class="br0">&#40;</span>entry<span class="sy0">,</span> numTabs<span class="sy0">+</span><span class="nu0">1</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; &nbsp;<span class="br0">&#125;</span> <span class="kw1">else</span> <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp;<span class="co1">// files have sizes, directories do not</span><br />
&nbsp; &nbsp; &nbsp; &nbsp;<span class="kw1">Serial</span>.<span class="kw1">print</span><span class="br0">&#40;</span><span class="st0">&quot;<span class="es1">\t</span><span class="es1">\t</span>&quot;</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp;<span class="kw1">Serial</span>.<span class="kw1">println</span><span class="br0">&#40;</span>entry.<span class="me1">size</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">,</span> <span class="kw2">DEC</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; &nbsp;<span class="br0">&#125;</span><br />
&nbsp; &nbsp;<span class="br0">&#125;</span><br />
<span class="br0">&#125;</span></div></div>
<div class='sourceblocklink'><a href='#' type='text/plain'>[Get Code]</a></div>
</div>
</p>
<p class='vspace'></p><h4>See Also</h4>
<ul><li><a class='wikilink' href='FileOpenNextFile.html'>openNextFile()</a>
</li><li><a class='wikilink' href='FileRewindDirectory.html'>rewindDirectory()</a>
</li></ul><p><a class='wikilink' href='index.html'>Reference Home</a>
</p>
<p class='vspace'></p><p><em>Corrections, suggestions, and new documentation should be posted to the <a class='urllink' href='http://arduino.cc/forum/index.php/board,23.0.html' rel='nofollow'>Forum</a>.</em>
</p>
<p class='vspace'></p><p>The text of the Arduino reference is licensed under a
<a class='urllink' href='http://creativecommons.org/licenses/by-sa/3.0/' rel='nofollow'>Creative Commons Attribution-ShareAlike 3.0 License</a>. Code samples in the reference are released into the public domain.
</p>
</div>
</div>
<!--PageFooterFmt-->
<div id="pagefooter">
&copy;Arduino |
<a href='#'>Edit Page</a> | <a href='#'>Page History</a> | <a href='#' target='_blank'>Printable View</a> | <a href='http://arduino.cc/en/Site/AllRecentChanges'>All Recent Site Changes</a>
</div>
<!--/PageFooterFmt-->
</div>
</body>
</html>

View File

@@ -0,0 +1,212 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>Arduino Reference - FileOpenNextFile </title>
<link rel="shortcut icon" type="image/x-icon" href="http://arduino.cc/en/favicon.png">
<link rel='stylesheet' href='arduinoWideRender.css'
type='text/css' />
<!--HeaderText--><style type='text/css'><!--
ul, ol, pre, dl, p { margin-top:0px; margin-bottom:0px; }
code { white-space: nowrap; }
.vspace { margin-top:1.33em; }
.indent { margin-left:40px; }
.outdent { margin-left:40px; text-indent:-40px; }
a.createlinktext { text-decoration:none; border-bottom:1px dotted gray; }
a.createlink { text-decoration:none; position:relative; top:-0.5em;
font-weight:bold; font-size:smaller; border-bottom:none; }
img { border:0px; }
.editconflict { color:green;
font-style:italic; margin-top:1.33em; margin-bottom:1.33em; }
table.markup { border: 2px dotted #ccf; width:90%; }
td.markup1, td.markup2 { padding-left:10px; padding-right:10px; }
td.markup1 { border-bottom: 1px solid #ccf; }
div.faq { margin-left:2em; }
div.faq p.question { margin: 1em 0 0.75em -2em; font-weight:bold; }
div.faq hr { margin-left: -2em; }
.frame
{ border:1px solid #cccccc; padding:4px; background-color:#f9f9f9; }
.lfloat { float:left; margin-right:0.5em; }
.rfloat { float:right; margin-left:0.5em; }
a.varlink { text-decoration:none; }
/**
* GeSHi (C) 2004 - 2007 Nigel McNie, 2007 - 2008 Benny Baumann
* (http://qbnz.com/highlighter/ and http://geshi.org/)
*/
.arduino {font-family:monospace;}
.arduino .imp {font-weight: bold; color: red;}
.arduino .kw1 {color: #CC6600;}
.arduino .kw2 {color: #006699;}
.arduino .kw3 {color: #CC6600; font-weight: bold;}
.arduino .co1 {color: #7E7E7E; font-style: italic;}
.arduino .co2 {color: #7E7E7E;}
.arduino .coMULTI {color: #7E7E7E; font-style: italic;}
.arduino .es0 {color: #000099; font-weight: bold;}
.arduino .es1 {color: #000099; font-weight: bold;}
.arduino .es2 {color: #660099; font-weight: bold;}
.arduino .es3 {color: #660099; font-weight: bold;}
.arduino .es4 {color: #660099; font-weight: bold;}
.arduino .es5 {color: #006699; font-weight: bold;}
.arduino .br0 {color: #000000;}
.arduino .sy0 {color: #000000;}
.arduino .st0 {color: #0066CC;}
.arduino .nu0 {color: #000000;}
.arduino .nu6 {color: #208080;}
.arduino .nu8 {color: #208080;}
.arduino .nu12 {color: #208080;}
.arduino .nu16 {color:#800080;}
.arduino .nu17 {color:#800080;}
.arduino .nu18 {color:#800080;}
.arduino .nu19 {color:#800080;}
.arduino .me1 {color: #ff1493;}
.arduino .me2 {color: #ff1493;}
.arduino span.xtra { display:block; }
.sourceblocklink {
text-align: right;
font-size: smaller;
}
.sourceblocktext {
padding: 0.5em;
color: #000000;
background-color: #ffffff;
}
.sourceblocktext div {
font-family: monospace;
font-size: small;
line-height: 1;
height: 1%;
}
.sourceblocktext div.head,
.sourceblocktext div.foot {
font: italic medium serif;
padding: 0.5em;
}
--></style> <meta name='robots' content='index,follow' />
<meta name="verify-v1" content="TtxFIEJAB6zdJ509wLxjnapQzKAMNm9u0Wj4ho6wxIY=" />
</head>
<body>
<div id="page">
<!--PageHeaderFmt-->
<div id="pageheader">
<div class="title"><a href='http://arduino.cc/en'>Arduino</a></div>
</div>
<!--/PageHeaderFmt-->
<!--PageLeftFmt-->
<div id="pagenav">
<div id="navbar">
<p><a class='wikilink' href='http://arduino.cc/en/Main/Buy'>Buy</a>
<a class='wikilink' href='http://arduino.cc/en/Main/Software'>Download</a>
<a class='wikilink' href='Guide_index.html'>Getting Started</a>
<a class='wikilink' href='http://arduino.cc/en/Tutorial/HomePage'>Learning</a>
<a class='wikilink' href='index.html'>Reference</a>
<a class='wikilink' href='http://arduino.cc/en/Main/Hardware'>Hardware</a>
<a class='wikilink' href='FAQ.html'>FAQ</a>
</p>
<p class='vspace'></p>
</div>
</div>
<!--/PageLeftFmt-->
<div id="pagetext">
<!--PageText-->
<div id='wikitext'>
<p><strong>Reference</strong> &nbsp; <a class='wikilink' href='index.html'>Language</a> | <a class='wikilink' href='Libraries.html'>Libraries</a> | <a class='wikilink' href='Comparison.html'>Comparison</a> | <a class='wikilink' href='Changes.html'>Changes</a>
</p>
<p class='vspace'></p><p><a class='wikilink' href='SD.html'>SD</a> : <em>File</em> class
</p>
<p class='vspace'></p><h2>openNextFile()</h2>
<p>Reports the next file or folder in a directory.
</p>
<p class='vspace'></p><h4>Syntax</h4>
<p><em>file</em>.openNextFile()
</p>
<p class='vspace'></p><h4>Parameters</h4>
<p><em>file</em>: an instance of the File class that is a directory
</p>
<p class='vspace'></p><h4>Returns</h4>
<p>char : the next file or folder in the path
</p>
<p class='vspace'></p><h4>Example</h4>
<p>
<div class='sourceblock ' id='sourceblock1'>
<div class='sourceblocktext'><div class="arduino"><span class="co2">#include &lt;SD.h&gt;</span><br />
<br />
File root<span class="sy0">;</span><br />
<br />
<span class="kw1">void</span> <span class="kw3">setup</span><span class="br0">&#40;</span><span class="br0">&#41;</span><br />
<span class="br0">&#123;</span><br />
&nbsp; <span class="kw1">Serial</span>.<span class="kw1">begin</span><span class="br0">&#40;</span><span class="nu0">9600</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; <span class="kw1">pinMode</span><span class="br0">&#40;</span><span class="nu0">10</span><span class="sy0">,</span> <span class="kw2">OUTPUT</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
<br />
&nbsp; SD.<span class="kw1">begin</span><span class="br0">&#40;</span><span class="nu0">10</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
<br />
&nbsp; root <span class="sy0">=</span> SD.<span class="me1">open</span><span class="br0">&#40;</span><span class="st0">&quot;/&quot;</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
<br />
&nbsp; printDirectory<span class="br0">&#40;</span>root<span class="sy0">,</span> <span class="nu0">0</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
<br />
&nbsp; <span class="kw1">Serial</span>.<span class="kw1">println</span><span class="br0">&#40;</span><span class="st0">&quot;done!&quot;</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
<span class="br0">&#125;</span><br />
<br />
<span class="kw1">void</span> <span class="kw3">loop</span><span class="br0">&#40;</span><span class="br0">&#41;</span><br />
<span class="br0">&#123;</span><br />
&nbsp; <span class="co1">// nothing happens after setup finishes.</span><br />
<span class="br0">&#125;</span><br />
<br />
<span class="kw1">void</span> printDirectory<span class="br0">&#40;</span>File dir<span class="sy0">,</span> <span class="kw1">int</span> numTabs<span class="br0">&#41;</span> <span class="br0">&#123;</span><br />
&nbsp; &nbsp;<span class="kw1">while</span><span class="br0">&#40;</span><span class="kw1">true</span><span class="br0">&#41;</span> <span class="br0">&#123;</span><br />
<br />
&nbsp; &nbsp; &nbsp;File entry <span class="sy0">=</span> &nbsp;dir.<span class="me1">openNextFile</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; &nbsp;<span class="kw1">if</span> <span class="br0">&#40;</span><span class="sy0">!</span> entry<span class="br0">&#41;</span> <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp;<span class="co1">// no more files</span><br />
&nbsp; &nbsp; &nbsp; &nbsp;<span class="kw1">Serial</span>.<span class="kw1">println</span><span class="br0">&#40;</span><span class="st0">&quot;**nomorefiles**&quot;</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; &nbsp;<span class="br0">&#125;</span><br />
&nbsp; &nbsp; &nbsp;<span class="kw1">for</span> <span class="br0">&#40;</span>uint8_t i<span class="sy0">=</span><span class="nu0">0</span><span class="sy0">;</span> i<span class="sy0">&lt;</span>numTabs<span class="sy0">;</span> i<span class="sy0">++</span><span class="br0">&#41;</span> <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp;<span class="kw1">Serial</span>.<span class="kw1">print</span><span class="br0">&#40;</span><span class="st0">'<span class="es1">\t</span>'</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; &nbsp;<span class="br0">&#125;</span><br />
&nbsp; &nbsp; &nbsp;<span class="kw1">Serial</span>.<span class="kw1">print</span><span class="br0">&#40;</span>entry.<span class="me1">name</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; &nbsp;<span class="kw1">if</span> <span class="br0">&#40;</span>entry.<span class="me1">isDirectory</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="br0">&#41;</span> <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp;<span class="kw1">Serial</span>.<span class="kw1">println</span><span class="br0">&#40;</span><span class="st0">&quot;/&quot;</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp;printDirectory<span class="br0">&#40;</span>entry<span class="sy0">,</span> numTabs<span class="sy0">+</span><span class="nu0">1</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; &nbsp;<span class="br0">&#125;</span> <span class="kw1">else</span> <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp;<span class="co1">// files have sizes, directories do not</span><br />
&nbsp; &nbsp; &nbsp; &nbsp;<span class="kw1">Serial</span>.<span class="kw1">print</span><span class="br0">&#40;</span><span class="st0">&quot;<span class="es1">\t</span><span class="es1">\t</span>&quot;</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp;<span class="kw1">Serial</span>.<span class="kw1">println</span><span class="br0">&#40;</span>entry.<span class="me1">size</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">,</span> <span class="kw2">DEC</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; &nbsp;<span class="br0">&#125;</span><br />
&nbsp; &nbsp;<span class="br0">&#125;</span><br />
<span class="br0">&#125;</span></div></div>
<div class='sourceblocklink'><a href='#' type='text/plain'>[Get Code]</a></div>
</div>
</p>
<p class='vspace'></p><h4>See Also</h4>
<ul><li><a class='wikilink' href='FileIsDirectory.html'>isDirectory()</a>
</li><li><a class='wikilink' href='FileRewindDirectory.html'>rewindDirectory()</a>
</li></ul><p><a class='wikilink' href='index.html'>Reference Home</a>
</p>
<p class='vspace'></p><p><em>Corrections, suggestions, and new documentation should be posted to the <a class='urllink' href='http://arduino.cc/forum/index.php/board,23.0.html' rel='nofollow'>Forum</a>.</em>
</p>
<p class='vspace'></p><p>The text of the Arduino reference is licensed under a
<a class='urllink' href='http://creativecommons.org/licenses/by-sa/3.0/' rel='nofollow'>Creative Commons Attribution-ShareAlike 3.0 License</a>. Code samples in the reference are released into the public domain.
</p>
</div>
</div>
<!--PageFooterFmt-->
<div id="pagefooter">
&copy;Arduino |
<a href='#'>Edit Page</a> | <a href='#'>Page History</a> | <a href='#' target='_blank'>Printable View</a> | <a href='http://arduino.cc/en/Site/AllRecentChanges'>All Recent Site Changes</a>
</div>
<!--/PageFooterFmt-->
</div>
</body>
</html>

View File

@@ -0,0 +1,109 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>Arduino Reference - FilePeek </title>
<link rel="shortcut icon" type="image/x-icon" href="http://arduino.cc/en/favicon.png">
<link rel='stylesheet' href='arduinoWideRender.css'
type='text/css' />
<!--HeaderText--><style type='text/css'><!--
ul, ol, pre, dl, p { margin-top:0px; margin-bottom:0px; }
code { white-space: nowrap; }
.vspace { margin-top:1.33em; }
.indent { margin-left:40px; }
.outdent { margin-left:40px; text-indent:-40px; }
a.createlinktext { text-decoration:none; border-bottom:1px dotted gray; }
a.createlink { text-decoration:none; position:relative; top:-0.5em;
font-weight:bold; font-size:smaller; border-bottom:none; }
img { border:0px; }
.editconflict { color:green;
font-style:italic; margin-top:1.33em; margin-bottom:1.33em; }
table.markup { border: 2px dotted #ccf; width:90%; }
td.markup1, td.markup2 { padding-left:10px; padding-right:10px; }
td.markup1 { border-bottom: 1px solid #ccf; }
div.faq { margin-left:2em; }
div.faq p.question { margin: 1em 0 0.75em -2em; font-weight:bold; }
div.faq hr { margin-left: -2em; }
.frame
{ border:1px solid #cccccc; padding:4px; background-color:#f9f9f9; }
.lfloat { float:left; margin-right:0.5em; }
.rfloat { float:right; margin-left:0.5em; }
a.varlink { text-decoration:none; }
--></style> <meta name='robots' content='index,follow' />
<meta name="verify-v1" content="TtxFIEJAB6zdJ509wLxjnapQzKAMNm9u0Wj4ho6wxIY=" />
</head>
<body>
<div id="page">
<!--PageHeaderFmt-->
<div id="pageheader">
<div class="title"><a href='http://arduino.cc/en'>Arduino</a></div>
</div>
<!--/PageHeaderFmt-->
<!--PageLeftFmt-->
<div id="pagenav">
<div id="navbar">
<p><a class='wikilink' href='http://arduino.cc/en/Main/Buy'>Buy</a>
<a class='wikilink' href='http://arduino.cc/en/Main/Software'>Download</a>
<a class='wikilink' href='Guide_index.html'>Getting Started</a>
<a class='wikilink' href='http://arduino.cc/en/Tutorial/HomePage'>Learning</a>
<a class='wikilink' href='index.html'>Reference</a>
<a class='wikilink' href='http://arduino.cc/en/Main/Hardware'>Hardware</a>
<a class='wikilink' href='FAQ.html'>FAQ</a>
</p>
<p class='vspace'></p>
</div>
</div>
<!--/PageLeftFmt-->
<div id="pagetext">
<!--PageText-->
<div id='wikitext'>
<p><strong>Reference</strong> &nbsp; <a class='wikilink' href='index.html'>Language</a> | <a class='wikilink' href='Libraries.html'>Libraries</a> | <a class='wikilink' href='Comparison.html'>Comparison</a> | <a class='wikilink' href='Changes.html'>Changes</a>
</p>
<p class='vspace'></p><p><a class='wikilink' href='SD.html'>SD</a> : <em>File</em> class
</p>
<p class='vspace'></p><h2>peek()</h2>
<p>Read a byte from the file without advancing to the next one. That is, successive calls to peek() will return the same value, as will the next call to read().
</p>
<p class='vspace'></p><p>peek() inherits from the <a class='wikilink' href='Stream.html'>Stream</a> utility class.
</p>
<p class='vspace'></p><h4>Syntax</h4>
<p><em>file</em>.peek()
</p>
<p class='vspace'></p><h4>Parameters</h4>
<p><em>file</em>: an instance of the File class (returned by <a class='wikilink' href='SDopen.html'>SD.open()</a>)
</p>
<p class='vspace'></p><h4>Returns</h4>
<p>The next byte (or character), or -1 if none is available.
</p>
<p class='vspace'></p><h4>See Also</h4>
<ul><li><a class='wikilink' href='FileAvailable.html'>available()</a>
</li><li><a class='wikilink' href='FileRead.html'>read()</a>
</li><li><a class='wikilink' href='FileWrite.html'>write()</a>
</li><li><a class='wikilink' href='StreamPeek.html'>Stream.peek()</a><br /><a class='wikilink' href='index.html'>Reference Home</a>
</li></ul><p class='vspace'></p><p><em>Corrections, suggestions, and new documentation should be posted to the <a class='urllink' href='http://arduino.cc/forum/index.php/board,23.0.html' rel='nofollow'>Forum</a>.</em>
</p>
<p class='vspace'></p><p>The text of the Arduino reference is licensed under a
<a class='urllink' href='http://creativecommons.org/licenses/by-sa/3.0/' rel='nofollow'>Creative Commons Attribution-ShareAlike 3.0 License</a>. Code samples in the reference are released into the public domain.
</p>
</div>
</div>
<!--PageFooterFmt-->
<div id="pagefooter">
&copy;Arduino |
<a href='#'>Edit Page</a> | <a href='#'>Page History</a> | <a href='#' target='_blank'>Printable View</a> | <a href='http://arduino.cc/en/Site/AllRecentChanges'>All Recent Site Changes</a>
</div>
<!--/PageFooterFmt-->
</div>
</body>
</html>

View File

@@ -0,0 +1,106 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>Arduino Reference - FilePosition </title>
<link rel="shortcut icon" type="image/x-icon" href="http://arduino.cc/en/favicon.png">
<link rel='stylesheet' href='arduinoWideRender.css'
type='text/css' />
<!--HeaderText--><style type='text/css'><!--
ul, ol, pre, dl, p { margin-top:0px; margin-bottom:0px; }
code { white-space: nowrap; }
.vspace { margin-top:1.33em; }
.indent { margin-left:40px; }
.outdent { margin-left:40px; text-indent:-40px; }
a.createlinktext { text-decoration:none; border-bottom:1px dotted gray; }
a.createlink { text-decoration:none; position:relative; top:-0.5em;
font-weight:bold; font-size:smaller; border-bottom:none; }
img { border:0px; }
.editconflict { color:green;
font-style:italic; margin-top:1.33em; margin-bottom:1.33em; }
table.markup { border: 2px dotted #ccf; width:90%; }
td.markup1, td.markup2 { padding-left:10px; padding-right:10px; }
td.markup1 { border-bottom: 1px solid #ccf; }
div.faq { margin-left:2em; }
div.faq p.question { margin: 1em 0 0.75em -2em; font-weight:bold; }
div.faq hr { margin-left: -2em; }
.frame
{ border:1px solid #cccccc; padding:4px; background-color:#f9f9f9; }
.lfloat { float:left; margin-right:0.5em; }
.rfloat { float:right; margin-left:0.5em; }
a.varlink { text-decoration:none; }
--></style> <meta name='robots' content='index,follow' />
<meta name="verify-v1" content="TtxFIEJAB6zdJ509wLxjnapQzKAMNm9u0Wj4ho6wxIY=" />
</head>
<body>
<div id="page">
<!--PageHeaderFmt-->
<div id="pageheader">
<div class="title"><a href='http://arduino.cc/en'>Arduino</a></div>
</div>
<!--/PageHeaderFmt-->
<!--PageLeftFmt-->
<div id="pagenav">
<div id="navbar">
<p><a class='wikilink' href='http://arduino.cc/en/Main/Buy'>Buy</a>
<a class='wikilink' href='http://arduino.cc/en/Main/Software'>Download</a>
<a class='wikilink' href='Guide_index.html'>Getting Started</a>
<a class='wikilink' href='http://arduino.cc/en/Tutorial/HomePage'>Learning</a>
<a class='wikilink' href='index.html'>Reference</a>
<a class='wikilink' href='http://arduino.cc/en/Main/Hardware'>Hardware</a>
<a class='wikilink' href='FAQ.html'>FAQ</a>
</p>
<p class='vspace'></p>
</div>
</div>
<!--/PageLeftFmt-->
<div id="pagetext">
<!--PageText-->
<div id='wikitext'>
<p><strong>Reference</strong> &nbsp; <a class='wikilink' href='index.html'>Language</a> | <a class='wikilink' href='Libraries.html'>Libraries</a> | <a class='wikilink' href='Comparison.html'>Comparison</a> | <a class='wikilink' href='Changes.html'>Changes</a>
</p>
<p class='vspace'></p><p><a class='wikilink' href='SD.html'>SD</a> : <em>File</em> class
</p>
<p class='vspace'></p><h2>position()</h2>
<p>Get the current position within the file (i.e. the location to which the next byte will be read from or written to).
</p>
<p class='vspace'></p><h4>Syntax</h4>
<p><em>file</em>.position()
</p>
<p class='vspace'></p><h4>Parameters</h4>
<p><em>file</em>: an instance of the File class (returned by <a class='wikilink' href='SDopen.html'>SD.open()</a>)
</p>
<p class='vspace'></p><h4>Returns</h4>
<p>the position within the file (<em>unsigned long</em>)
</p>
<p class='vspace'></p><h4>See Also</h4>
<ul><li><a class='wikilink' href='FileSeek.html'>seek()</a>
</li></ul><p><a class='wikilink' href='index.html'>Reference Home</a>
</p>
<p class='vspace'></p><p><em>Corrections, suggestions, and new documentation should be posted to the <a class='urllink' href='http://arduino.cc/forum/index.php/board,23.0.html' rel='nofollow'>Forum</a>.</em>
</p>
<p class='vspace'></p><p>The text of the Arduino reference is licensed under a
<a class='urllink' href='http://creativecommons.org/licenses/by-sa/3.0/' rel='nofollow'>Creative Commons Attribution-ShareAlike 3.0 License</a>. Code samples in the reference are released into the public domain.
</p>
</div>
</div>
<!--PageFooterFmt-->
<div id="pagefooter">
&copy;Arduino |
<a href='#'>Edit Page</a> | <a href='#'>Page History</a> | <a href='#' target='_blank'>Printable View</a> | <a href='http://arduino.cc/en/Site/AllRecentChanges'>All Recent Site Changes</a>
</div>
<!--/PageFooterFmt-->
</div>
</body>
</html>

View File

@@ -0,0 +1,112 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>Arduino Reference - FilePrint </title>
<link rel="shortcut icon" type="image/x-icon" href="http://arduino.cc/en/favicon.png">
<link rel='stylesheet' href='arduinoWideRender.css'
type='text/css' />
<!--HeaderText--><style type='text/css'><!--
ul, ol, pre, dl, p { margin-top:0px; margin-bottom:0px; }
code { white-space: nowrap; }
.vspace { margin-top:1.33em; }
.indent { margin-left:40px; }
.outdent { margin-left:40px; text-indent:-40px; }
a.createlinktext { text-decoration:none; border-bottom:1px dotted gray; }
a.createlink { text-decoration:none; position:relative; top:-0.5em;
font-weight:bold; font-size:smaller; border-bottom:none; }
img { border:0px; }
.editconflict { color:green;
font-style:italic; margin-top:1.33em; margin-bottom:1.33em; }
table.markup { border: 2px dotted #ccf; width:90%; }
td.markup1, td.markup2 { padding-left:10px; padding-right:10px; }
td.markup1 { border-bottom: 1px solid #ccf; }
div.faq { margin-left:2em; }
div.faq p.question { margin: 1em 0 0.75em -2em; font-weight:bold; }
div.faq hr { margin-left: -2em; }
.frame
{ border:1px solid #cccccc; padding:4px; background-color:#f9f9f9; }
.lfloat { float:left; margin-right:0.5em; }
.rfloat { float:right; margin-left:0.5em; }
a.varlink { text-decoration:none; }
--></style> <meta name='robots' content='index,follow' />
<meta name="verify-v1" content="TtxFIEJAB6zdJ509wLxjnapQzKAMNm9u0Wj4ho6wxIY=" />
</head>
<body>
<div id="page">
<!--PageHeaderFmt-->
<div id="pageheader">
<div class="title"><a href='http://arduino.cc/en'>Arduino</a></div>
</div>
<!--/PageHeaderFmt-->
<!--PageLeftFmt-->
<div id="pagenav">
<div id="navbar">
<p><a class='wikilink' href='http://arduino.cc/en/Main/Buy'>Buy</a>
<a class='wikilink' href='http://arduino.cc/en/Main/Software'>Download</a>
<a class='wikilink' href='Guide_index.html'>Getting Started</a>
<a class='wikilink' href='http://arduino.cc/en/Tutorial/HomePage'>Learning</a>
<a class='wikilink' href='index.html'>Reference</a>
<a class='wikilink' href='http://arduino.cc/en/Main/Hardware'>Hardware</a>
<a class='wikilink' href='FAQ.html'>FAQ</a>
</p>
<p class='vspace'></p>
</div>
</div>
<!--/PageLeftFmt-->
<div id="pagetext">
<!--PageText-->
<div id='wikitext'>
<p><strong>Reference</strong> &nbsp; <a class='wikilink' href='index.html'>Language</a> | <a class='wikilink' href='Libraries.html'>Libraries</a> | <a class='wikilink' href='Comparison.html'>Comparison</a> | <a class='wikilink' href='Changes.html'>Changes</a>
</p>
<p class='vspace'></p><p><a class='wikilink' href='SD.html'>SD</a> : <em>File</em> class
</p>
<p class='vspace'></p><h2>print()</h2>
<h4>Description</h4>
<p>Print data to the file, which must have been opened for writing. Prints numbers as a sequence of digits, each an ASCII character (e.g. the number 123 is sent as the three characters '1', '2', '3').
</p>
<p class='vspace'></p><h4>Syntax</h4>
<p><em>file</em>.print(data) <br /><em>file</em>.print(data, BASE)
</p>
<p class='vspace'></p><h4>Parameters</h4>
<p><em>file</em>: an instance of the File class (returned by <a class='wikilink' href='SDopen.html'>SD.open()</a>)
</p>
<p class='vspace'></p><p>data: the data to print (char, byte, int, long, or string)
</p>
<p class='vspace'></p><p>BASE (optional): the base in which to print numbers: BIN for binary (base 2), DEC for decimal (base 10), OCT for octal (base 8), HEX for hexadecimal (base 16).
</p>
<p class='vspace'></p><h4>Returns</h4>
<p>byte<br />print() will return the number of bytes written, though reading that number is optional
</p>
<p class='vspace'></p><h4>See Also</h4>
<ul><li><a class='wikilink' href='FilePrintln.html'>println()</a>
</li><li><a class='wikilink' href='FileWrite.html'>write()</a>
</li></ul><p class='vspace'></p><p><a class='wikilink' href='index.html'>Reference Home</a>
</p>
<p class='vspace'></p><p><em>Corrections, suggestions, and new documentation should be posted to the <a class='urllink' href='http://arduino.cc/forum/index.php/board,23.0.html' rel='nofollow'>Forum</a>.</em>
</p>
<p class='vspace'></p><p>The text of the Arduino reference is licensed under a
<a class='urllink' href='http://creativecommons.org/licenses/by-sa/3.0/' rel='nofollow'>Creative Commons Attribution-ShareAlike 3.0 License</a>. Code samples in the reference are released into the public domain.
</p>
</div>
</div>
<!--PageFooterFmt-->
<div id="pagefooter">
&copy;Arduino |
<a href='#'>Edit Page</a> | <a href='#'>Page History</a> | <a href='#' target='_blank'>Printable View</a> | <a href='http://arduino.cc/en/Site/AllRecentChanges'>All Recent Site Changes</a>
</div>
<!--/PageFooterFmt-->
</div>
</body>
</html>

View File

@@ -0,0 +1,112 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>Arduino Reference - FilePrintln </title>
<link rel="shortcut icon" type="image/x-icon" href="http://arduino.cc/en/favicon.png">
<link rel='stylesheet' href='arduinoWideRender.css'
type='text/css' />
<!--HeaderText--><style type='text/css'><!--
ul, ol, pre, dl, p { margin-top:0px; margin-bottom:0px; }
code { white-space: nowrap; }
.vspace { margin-top:1.33em; }
.indent { margin-left:40px; }
.outdent { margin-left:40px; text-indent:-40px; }
a.createlinktext { text-decoration:none; border-bottom:1px dotted gray; }
a.createlink { text-decoration:none; position:relative; top:-0.5em;
font-weight:bold; font-size:smaller; border-bottom:none; }
img { border:0px; }
.editconflict { color:green;
font-style:italic; margin-top:1.33em; margin-bottom:1.33em; }
table.markup { border: 2px dotted #ccf; width:90%; }
td.markup1, td.markup2 { padding-left:10px; padding-right:10px; }
td.markup1 { border-bottom: 1px solid #ccf; }
div.faq { margin-left:2em; }
div.faq p.question { margin: 1em 0 0.75em -2em; font-weight:bold; }
div.faq hr { margin-left: -2em; }
.frame
{ border:1px solid #cccccc; padding:4px; background-color:#f9f9f9; }
.lfloat { float:left; margin-right:0.5em; }
.rfloat { float:right; margin-left:0.5em; }
a.varlink { text-decoration:none; }
--></style> <meta name='robots' content='index,follow' />
<meta name="verify-v1" content="TtxFIEJAB6zdJ509wLxjnapQzKAMNm9u0Wj4ho6wxIY=" />
</head>
<body>
<div id="page">
<!--PageHeaderFmt-->
<div id="pageheader">
<div class="title"><a href='http://arduino.cc/en'>Arduino</a></div>
</div>
<!--/PageHeaderFmt-->
<!--PageLeftFmt-->
<div id="pagenav">
<div id="navbar">
<p><a class='wikilink' href='http://arduino.cc/en/Main/Buy'>Buy</a>
<a class='wikilink' href='http://arduino.cc/en/Main/Software'>Download</a>
<a class='wikilink' href='Guide_index.html'>Getting Started</a>
<a class='wikilink' href='http://arduino.cc/en/Tutorial/HomePage'>Learning</a>
<a class='wikilink' href='index.html'>Reference</a>
<a class='wikilink' href='http://arduino.cc/en/Main/Hardware'>Hardware</a>
<a class='wikilink' href='FAQ.html'>FAQ</a>
</p>
<p class='vspace'></p>
</div>
</div>
<!--/PageLeftFmt-->
<div id="pagetext">
<!--PageText-->
<div id='wikitext'>
<p><strong>Reference</strong> &nbsp; <a class='wikilink' href='index.html'>Language</a> | <a class='wikilink' href='Libraries.html'>Libraries</a> | <a class='wikilink' href='Comparison.html'>Comparison</a> | <a class='wikilink' href='Changes.html'>Changes</a>
</p>
<p class='vspace'></p><p><a class='wikilink' href='SD.html'>SD</a> : <em>File</em> class
</p>
<p class='vspace'></p><h2>println()</h2>
<h4>Description</h4>
<p>Print data, followed by a carriage return and newline, to the File, which must have been opened for writing. Prints numbers as a sequence of digits, each an ASCII character (e.g. the number 123 is sent as the three characters '1', '2', '3').
</p>
<p class='vspace'></p><h4>Syntax</h4>
<p><em>file</em>.println() <br /><em>file</em>.println(data) <br /><em>file</em>.print(data, BASE)
</p>
<p class='vspace'></p><h4>Parameters</h4>
<p><em>file</em>: an instance of the File class (returned by <a class='wikilink' href='SDopen.html'>SD.open()</a>)
</p>
<p class='vspace'></p><p>data (optional): the data to print (char, byte, int, long, or string)
</p>
<p class='vspace'></p><p>BASE (optional): the base in which to print numbers: BIN for binary (base 2), DEC for decimal (base 10), OCT for octal (base 8), HEX for hexadecimal (base 16).
</p>
<p class='vspace'></p><h4>Returns</h4>
<p>byte<br />println() will return the number of bytes written, though reading that number is optional
</p>
<p class='vspace'></p><h4>See Also</h4>
<ul><li><a class='wikilink' href='FilePrint.html'>print()</a>
</li><li><a class='wikilink' href='FileWrite.html'>write()</a>
</li></ul><p class='vspace'></p><p><a class='wikilink' href='index.html'>Reference Home</a>
</p>
<p class='vspace'></p><p><em>Corrections, suggestions, and new documentation should be posted to the <a class='urllink' href='http://arduino.cc/forum/index.php/board,23.0.html' rel='nofollow'>Forum</a>.</em>
</p>
<p class='vspace'></p><p>The text of the Arduino reference is licensed under a
<a class='urllink' href='http://creativecommons.org/licenses/by-sa/3.0/' rel='nofollow'>Creative Commons Attribution-ShareAlike 3.0 License</a>. Code samples in the reference are released into the public domain.
</p>
</div>
</div>
<!--PageFooterFmt-->
<div id="pagefooter">
&copy;Arduino |
<a href='#'>Edit Page</a> | <a href='#'>Page History</a> | <a href='#' target='_blank'>Printable View</a> | <a href='http://arduino.cc/en/Site/AllRecentChanges'>All Recent Site Changes</a>
</div>
<!--/PageFooterFmt-->
</div>
</body>
</html>

View File

@@ -0,0 +1,111 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>Arduino Reference - FileRead </title>
<link rel="shortcut icon" type="image/x-icon" href="http://arduino.cc/en/favicon.png">
<link rel='stylesheet' href='arduinoWideRender.css'
type='text/css' />
<!--HeaderText--><style type='text/css'><!--
ul, ol, pre, dl, p { margin-top:0px; margin-bottom:0px; }
code { white-space: nowrap; }
.vspace { margin-top:1.33em; }
.indent { margin-left:40px; }
.outdent { margin-left:40px; text-indent:-40px; }
a.createlinktext { text-decoration:none; border-bottom:1px dotted gray; }
a.createlink { text-decoration:none; position:relative; top:-0.5em;
font-weight:bold; font-size:smaller; border-bottom:none; }
img { border:0px; }
.editconflict { color:green;
font-style:italic; margin-top:1.33em; margin-bottom:1.33em; }
table.markup { border: 2px dotted #ccf; width:90%; }
td.markup1, td.markup2 { padding-left:10px; padding-right:10px; }
td.markup1 { border-bottom: 1px solid #ccf; }
div.faq { margin-left:2em; }
div.faq p.question { margin: 1em 0 0.75em -2em; font-weight:bold; }
div.faq hr { margin-left: -2em; }
.frame
{ border:1px solid #cccccc; padding:4px; background-color:#f9f9f9; }
.lfloat { float:left; margin-right:0.5em; }
.rfloat { float:right; margin-left:0.5em; }
a.varlink { text-decoration:none; }
--></style> <meta name='robots' content='index,follow' />
<meta name="verify-v1" content="TtxFIEJAB6zdJ509wLxjnapQzKAMNm9u0Wj4ho6wxIY=" />
</head>
<body>
<div id="page">
<!--PageHeaderFmt-->
<div id="pageheader">
<div class="title"><a href='http://arduino.cc/en'>Arduino</a></div>
</div>
<!--/PageHeaderFmt-->
<!--PageLeftFmt-->
<div id="pagenav">
<div id="navbar">
<p><a class='wikilink' href='http://arduino.cc/en/Main/Buy'>Buy</a>
<a class='wikilink' href='http://arduino.cc/en/Main/Software'>Download</a>
<a class='wikilink' href='Guide_index.html'>Getting Started</a>
<a class='wikilink' href='http://arduino.cc/en/Tutorial/HomePage'>Learning</a>
<a class='wikilink' href='index.html'>Reference</a>
<a class='wikilink' href='http://arduino.cc/en/Main/Hardware'>Hardware</a>
<a class='wikilink' href='FAQ.html'>FAQ</a>
</p>
<p class='vspace'></p>
</div>
</div>
<!--/PageLeftFmt-->
<div id="pagetext">
<!--PageText-->
<div id='wikitext'>
<p><strong>Reference</strong> &nbsp; <a class='wikilink' href='index.html'>Language</a> | <a class='wikilink' href='Libraries.html'>Libraries</a> | <a class='wikilink' href='Comparison.html'>Comparison</a> | <a class='wikilink' href='Changes.html'>Changes</a>
</p>
<p class='vspace'></p><p><a class='wikilink' href='SD.html'>SD</a> : <em>File</em> class
</p>
<p class='vspace'></p><h2>read()</h2>
<p>Read a byte from the file.
</p>
<p class='vspace'></p><p>read() inherits from the <a class='wikilink' href='Stream.html'>Stream</a> utility class.
</p>
<p class='vspace'></p><h4>Syntax</h4>
<p><em>file</em>.read()
</p>
<p class='vspace'></p><h4>Parameters</h4>
<p><em>file</em>: an instance of the File class (returned by <a class='wikilink' href='SDopen.html'>SD.open()</a>)
</p>
<p class='vspace'></p><h4>Returns</h4>
<p>The next byte (or character), or -1 if none is available.
</p>
<p class='vspace'></p><h4>See Also</h4>
<ul><li><a class='wikilink' href='FileAvailable.html'>available()</a>
</li><li><a class='wikilink' href='FilePeek.html'>peek()</a>
</li><li><a class='wikilink' href='FileWrite.html'>write()</a>
</li><li><a class='wikilink' href='StreamRead.html'>Stream.read()</a>
</li></ul><p><a class='wikilink' href='index.html'>Reference Home</a>
</p>
<p class='vspace'></p><p><em>Corrections, suggestions, and new documentation should be posted to the <a class='urllink' href='http://arduino.cc/forum/index.php/board,23.0.html' rel='nofollow'>Forum</a>.</em>
</p>
<p class='vspace'></p><p>The text of the Arduino reference is licensed under a
<a class='urllink' href='http://creativecommons.org/licenses/by-sa/3.0/' rel='nofollow'>Creative Commons Attribution-ShareAlike 3.0 License</a>. Code samples in the reference are released into the public domain.
</p>
</div>
</div>
<!--PageFooterFmt-->
<div id="pagefooter">
&copy;Arduino |
<a href='#'>Edit Page</a> | <a href='#'>Page History</a> | <a href='#' target='_blank'>Printable View</a> | <a href='http://arduino.cc/en/Site/AllRecentChanges'>All Recent Site Changes</a>
</div>
<!--/PageFooterFmt-->
</div>
</body>
</html>

View File

@@ -0,0 +1,215 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>Arduino Reference - FileRewindDirectory </title>
<link rel="shortcut icon" type="image/x-icon" href="http://arduino.cc/en/favicon.png">
<link rel='stylesheet' href='arduinoWideRender.css'
type='text/css' />
<!--HeaderText--><style type='text/css'><!--
ul, ol, pre, dl, p { margin-top:0px; margin-bottom:0px; }
code { white-space: nowrap; }
.vspace { margin-top:1.33em; }
.indent { margin-left:40px; }
.outdent { margin-left:40px; text-indent:-40px; }
a.createlinktext { text-decoration:none; border-bottom:1px dotted gray; }
a.createlink { text-decoration:none; position:relative; top:-0.5em;
font-weight:bold; font-size:smaller; border-bottom:none; }
img { border:0px; }
.editconflict { color:green;
font-style:italic; margin-top:1.33em; margin-bottom:1.33em; }
table.markup { border: 2px dotted #ccf; width:90%; }
td.markup1, td.markup2 { padding-left:10px; padding-right:10px; }
td.markup1 { border-bottom: 1px solid #ccf; }
div.faq { margin-left:2em; }
div.faq p.question { margin: 1em 0 0.75em -2em; font-weight:bold; }
div.faq hr { margin-left: -2em; }
.frame
{ border:1px solid #cccccc; padding:4px; background-color:#f9f9f9; }
.lfloat { float:left; margin-right:0.5em; }
.rfloat { float:right; margin-left:0.5em; }
a.varlink { text-decoration:none; }
/**
* GeSHi (C) 2004 - 2007 Nigel McNie, 2007 - 2008 Benny Baumann
* (http://qbnz.com/highlighter/ and http://geshi.org/)
*/
.arduino {font-family:monospace;}
.arduino .imp {font-weight: bold; color: red;}
.arduino .kw1 {color: #CC6600;}
.arduino .kw2 {color: #006699;}
.arduino .kw3 {color: #CC6600; font-weight: bold;}
.arduino .co1 {color: #7E7E7E; font-style: italic;}
.arduino .co2 {color: #7E7E7E;}
.arduino .coMULTI {color: #7E7E7E; font-style: italic;}
.arduino .es0 {color: #000099; font-weight: bold;}
.arduino .es1 {color: #000099; font-weight: bold;}
.arduino .es2 {color: #660099; font-weight: bold;}
.arduino .es3 {color: #660099; font-weight: bold;}
.arduino .es4 {color: #660099; font-weight: bold;}
.arduino .es5 {color: #006699; font-weight: bold;}
.arduino .br0 {color: #000000;}
.arduino .sy0 {color: #000000;}
.arduino .st0 {color: #0066CC;}
.arduino .nu0 {color: #000000;}
.arduino .nu6 {color: #208080;}
.arduino .nu8 {color: #208080;}
.arduino .nu12 {color: #208080;}
.arduino .nu16 {color:#800080;}
.arduino .nu17 {color:#800080;}
.arduino .nu18 {color:#800080;}
.arduino .nu19 {color:#800080;}
.arduino .me1 {color: #ff1493;}
.arduino .me2 {color: #ff1493;}
.arduino span.xtra { display:block; }
.sourceblocklink {
text-align: right;
font-size: smaller;
}
.sourceblocktext {
padding: 0.5em;
color: #000000;
background-color: #ffffff;
}
.sourceblocktext div {
font-family: monospace;
font-size: small;
line-height: 1;
height: 1%;
}
.sourceblocktext div.head,
.sourceblocktext div.foot {
font: italic medium serif;
padding: 0.5em;
}
--></style> <meta name='robots' content='index,follow' />
<meta name="verify-v1" content="TtxFIEJAB6zdJ509wLxjnapQzKAMNm9u0Wj4ho6wxIY=" />
</head>
<body>
<div id="page">
<!--PageHeaderFmt-->
<div id="pageheader">
<div class="title"><a href='http://arduino.cc/en'>Arduino</a></div>
</div>
<!--/PageHeaderFmt-->
<!--PageLeftFmt-->
<div id="pagenav">
<div id="navbar">
<p><a class='wikilink' href='http://arduino.cc/en/Main/Buy'>Buy</a>
<a class='wikilink' href='http://arduino.cc/en/Main/Software'>Download</a>
<a class='wikilink' href='Guide_index.html'>Getting Started</a>
<a class='wikilink' href='http://arduino.cc/en/Tutorial/HomePage'>Learning</a>
<a class='wikilink' href='index.html'>Reference</a>
<a class='wikilink' href='http://arduino.cc/en/Main/Hardware'>Hardware</a>
<a class='wikilink' href='FAQ.html'>FAQ</a>
</p>
<p class='vspace'></p>
</div>
</div>
<!--/PageLeftFmt-->
<div id="pagetext">
<!--PageText-->
<div id='wikitext'>
<p><strong>Reference</strong> &nbsp; <a class='wikilink' href='index.html'>Language</a> | <a class='wikilink' href='Libraries.html'>Libraries</a> | <a class='wikilink' href='Comparison.html'>Comparison</a> | <a class='wikilink' href='Changes.html'>Changes</a>
</p>
<p class='vspace'></p><p><a class='wikilink' href='SD.html'>SD</a> : <em>File</em> class
</p>
<p class='vspace'></p><h2>rewindDirectory()</h2>
<p>rewindDirectory() will bring you back to the first file in the directory, used in conjunction with <a class='wikilink' href='FileOpenNextFile.html'>openNextFile()</a>.
</p>
<p class='vspace'></p><h4>Syntax</h4>
<p><em>file</em>.rewindDirectory()
</p>
<p class='vspace'></p><h4>Parameters</h4>
<p><em>file</em>: an instance of the File class.
</p>
<p class='vspace'></p><h4>Returns</h4>
<p>None
</p>
<p class='vspace'></p><p>
<div class='sourceblock ' id='sourceblock1'>
<div class='sourceblocktext'><div class="arduino"><span class="co2">#include &lt;SD.h&gt;</span><br />
<br />
File root<span class="sy0">;</span><br />
<br />
<span class="kw1">void</span> <span class="kw3">setup</span><span class="br0">&#40;</span><span class="br0">&#41;</span><br />
<span class="br0">&#123;</span><br />
&nbsp; <span class="kw1">Serial</span>.<span class="kw1">begin</span><span class="br0">&#40;</span><span class="nu0">9600</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; <span class="kw1">pinMode</span><span class="br0">&#40;</span><span class="nu0">10</span><span class="sy0">,</span> <span class="kw2">OUTPUT</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
<br />
&nbsp; SD.<span class="kw1">begin</span><span class="br0">&#40;</span><span class="nu0">10</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
<br />
&nbsp; root <span class="sy0">=</span> SD.<span class="me1">open</span><span class="br0">&#40;</span><span class="st0">&quot;/&quot;</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
<br />
&nbsp; printDirectory<span class="br0">&#40;</span>root<span class="sy0">,</span> <span class="nu0">0</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
<br />
&nbsp; <span class="kw1">Serial</span>.<span class="kw1">println</span><span class="br0">&#40;</span><span class="st0">&quot;done!&quot;</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
<span class="br0">&#125;</span><br />
<br />
<span class="kw1">void</span> <span class="kw3">loop</span><span class="br0">&#40;</span><span class="br0">&#41;</span><br />
<span class="br0">&#123;</span><br />
&nbsp; <span class="co1">// nothing happens after setup finishes.</span><br />
<span class="br0">&#125;</span><br />
<br />
<span class="kw1">void</span> printDirectory<span class="br0">&#40;</span>File dir<span class="sy0">,</span> <span class="kw1">int</span> numTabs<span class="br0">&#41;</span> <span class="br0">&#123;</span><br />
&nbsp; &nbsp;<span class="kw1">while</span><span class="br0">&#40;</span><span class="kw1">true</span><span class="br0">&#41;</span> <span class="br0">&#123;</span><br />
<br />
&nbsp; &nbsp; &nbsp;File entry <span class="sy0">=</span> &nbsp;dir.<span class="me1">openNextFile</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; &nbsp;<span class="kw1">if</span> <span class="br0">&#40;</span><span class="sy0">!</span> entry<span class="br0">&#41;</span> <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp;<span class="co1">// no more files</span><br />
&nbsp; &nbsp; &nbsp; &nbsp;<span class="co1">// return to the first file in the directory</span><br />
&nbsp; &nbsp; &nbsp; &nbsp;dir.<span class="me1">rewindDirectory</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp;<span class="kw1">break</span><span class="sy0">;</span><br />
&nbsp; &nbsp; &nbsp;<span class="br0">&#125;</span><br />
&nbsp; &nbsp; &nbsp;<span class="kw1">for</span> <span class="br0">&#40;</span>uint8_t i<span class="sy0">=</span><span class="nu0">0</span><span class="sy0">;</span> i<span class="sy0">&lt;</span>numTabs<span class="sy0">;</span> i<span class="sy0">++</span><span class="br0">&#41;</span> <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp;<span class="kw1">Serial</span>.<span class="kw1">print</span><span class="br0">&#40;</span><span class="st0">'<span class="es1">\t</span>'</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; &nbsp;<span class="br0">&#125;</span><br />
&nbsp; &nbsp; &nbsp;<span class="kw1">Serial</span>.<span class="kw1">print</span><span class="br0">&#40;</span>entry.<span class="me1">name</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; &nbsp;<span class="kw1">if</span> <span class="br0">&#40;</span>entry.<span class="me1">isDirectory</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="br0">&#41;</span> <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp;<span class="kw1">Serial</span>.<span class="kw1">println</span><span class="br0">&#40;</span><span class="st0">&quot;/&quot;</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp;printDirectory<span class="br0">&#40;</span>entry<span class="sy0">,</span> numTabs<span class="sy0">+</span><span class="nu0">1</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; &nbsp;<span class="br0">&#125;</span> <span class="kw1">else</span> <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp;<span class="co1">// files have sizes, directories do not</span><br />
&nbsp; &nbsp; &nbsp; &nbsp;<span class="kw1">Serial</span>.<span class="kw1">print</span><span class="br0">&#40;</span><span class="st0">&quot;<span class="es1">\t</span><span class="es1">\t</span>&quot;</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp;<span class="kw1">Serial</span>.<span class="kw1">println</span><span class="br0">&#40;</span>entry.<span class="me1">size</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">,</span> <span class="kw2">DEC</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; &nbsp;<span class="br0">&#125;</span><br />
&nbsp; &nbsp;<span class="br0">&#125;</span><br />
<span class="br0">&#125;</span><br />
&nbsp;</div></div>
<div class='sourceblocklink'><a href='#' type='text/plain'>[Get Code]</a></div>
</div>
</p>
<p class='vspace'></p><h4>See Also</h4>
<ul><li><a class='wikilink' href='SDopen.html'>open()</a>
</li><li><a class='wikilink' href='FileOpenNextFile.html'>openNextFile()</a>
</li><li><a class='wikilink' href='FileIsDirectory.html'>isDirectory()</a>
</li></ul><p><a class='wikilink' href='index.html'>Reference Home</a>
</p>
<p class='vspace'></p><p><em>Corrections, suggestions, and new documentation should be posted to the <a class='urllink' href='http://arduino.cc/forum/index.php/board,23.0.html' rel='nofollow'>Forum</a>.</em>
</p>
<p class='vspace'></p><p>The text of the Arduino reference is licensed under a
<a class='urllink' href='http://creativecommons.org/licenses/by-sa/3.0/' rel='nofollow'>Creative Commons Attribution-ShareAlike 3.0 License</a>. Code samples in the reference are released into the public domain.
</p>
</div>
</div>
<!--PageFooterFmt-->
<div id="pagefooter">
&copy;Arduino |
<a href='#'>Edit Page</a> | <a href='#'>Page History</a> | <a href='#' target='_blank'>Printable View</a> | <a href='http://arduino.cc/en/Site/AllRecentChanges'>All Recent Site Changes</a>
</div>
<!--/PageFooterFmt-->
</div>
</body>
</html>

View File

@@ -0,0 +1,108 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>Arduino Reference - FileSeek </title>
<link rel="shortcut icon" type="image/x-icon" href="http://arduino.cc/en/favicon.png">
<link rel='stylesheet' href='arduinoWideRender.css'
type='text/css' />
<!--HeaderText--><style type='text/css'><!--
ul, ol, pre, dl, p { margin-top:0px; margin-bottom:0px; }
code { white-space: nowrap; }
.vspace { margin-top:1.33em; }
.indent { margin-left:40px; }
.outdent { margin-left:40px; text-indent:-40px; }
a.createlinktext { text-decoration:none; border-bottom:1px dotted gray; }
a.createlink { text-decoration:none; position:relative; top:-0.5em;
font-weight:bold; font-size:smaller; border-bottom:none; }
img { border:0px; }
.editconflict { color:green;
font-style:italic; margin-top:1.33em; margin-bottom:1.33em; }
table.markup { border: 2px dotted #ccf; width:90%; }
td.markup1, td.markup2 { padding-left:10px; padding-right:10px; }
td.markup1 { border-bottom: 1px solid #ccf; }
div.faq { margin-left:2em; }
div.faq p.question { margin: 1em 0 0.75em -2em; font-weight:bold; }
div.faq hr { margin-left: -2em; }
.frame
{ border:1px solid #cccccc; padding:4px; background-color:#f9f9f9; }
.lfloat { float:left; margin-right:0.5em; }
.rfloat { float:right; margin-left:0.5em; }
a.varlink { text-decoration:none; }
--></style> <meta name='robots' content='index,follow' />
<meta name="verify-v1" content="TtxFIEJAB6zdJ509wLxjnapQzKAMNm9u0Wj4ho6wxIY=" />
</head>
<body>
<div id="page">
<!--PageHeaderFmt-->
<div id="pageheader">
<div class="title"><a href='http://arduino.cc/en'>Arduino</a></div>
</div>
<!--/PageHeaderFmt-->
<!--PageLeftFmt-->
<div id="pagenav">
<div id="navbar">
<p><a class='wikilink' href='http://arduino.cc/en/Main/Buy'>Buy</a>
<a class='wikilink' href='http://arduino.cc/en/Main/Software'>Download</a>
<a class='wikilink' href='Guide_index.html'>Getting Started</a>
<a class='wikilink' href='http://arduino.cc/en/Tutorial/HomePage'>Learning</a>
<a class='wikilink' href='index.html'>Reference</a>
<a class='wikilink' href='http://arduino.cc/en/Main/Hardware'>Hardware</a>
<a class='wikilink' href='FAQ.html'>FAQ</a>
</p>
<p class='vspace'></p>
</div>
</div>
<!--/PageLeftFmt-->
<div id="pagetext">
<!--PageText-->
<div id='wikitext'>
<p><strong>Reference</strong> &nbsp; <a class='wikilink' href='index.html'>Language</a> | <a class='wikilink' href='Libraries.html'>Libraries</a> | <a class='wikilink' href='Comparison.html'>Comparison</a> | <a class='wikilink' href='Changes.html'>Changes</a>
</p>
<p class='vspace'></p><p><a class='wikilink' href='SD.html'>SD</a> : <em>File</em> class
</p>
<p class='vspace'></p><h2>seek()</h2>
<p>Seek to a new position in the file, which must be between 0 and the size of the file (inclusive).
</p>
<p class='vspace'></p><h4>Syntax</h4>
<p><em>file</em>.seek(pos)
</p>
<p class='vspace'></p><h4>Parameters</h4>
<p><em>file</em>: an instance of the File class (returned by <a class='wikilink' href='SDopen.html'>SD.open()</a>)
</p>
<p class='vspace'></p><p>pos: the position to which to seek (<em>unsigned long</em>)
</p>
<p class='vspace'></p><h4>Returns</h4>
<p>true for success, false for failure (<em>boolean</em>)
</p>
<p class='vspace'></p><h4>See Also</h4>
<ul><li><a class='wikilink' href='FilePosition.html'>position()</a>
</li></ul><p><a class='wikilink' href='index.html'>Reference Home</a>
</p>
<p class='vspace'></p><p><em>Corrections, suggestions, and new documentation should be posted to the <a class='urllink' href='http://arduino.cc/forum/index.php/board,23.0.html' rel='nofollow'>Forum</a>.</em>
</p>
<p class='vspace'></p><p>The text of the Arduino reference is licensed under a
<a class='urllink' href='http://creativecommons.org/licenses/by-sa/3.0/' rel='nofollow'>Creative Commons Attribution-ShareAlike 3.0 License</a>. Code samples in the reference are released into the public domain.
</p>
</div>
</div>
<!--PageFooterFmt-->
<div id="pagefooter">
&copy;Arduino |
<a href='#'>Edit Page</a> | <a href='#'>Page History</a> | <a href='#' target='_blank'>Printable View</a> | <a href='http://arduino.cc/en/Site/AllRecentChanges'>All Recent Site Changes</a>
</div>
<!--/PageFooterFmt-->
</div>
</body>
</html>

View File

@@ -0,0 +1,104 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>Arduino Reference - FileSize </title>
<link rel="shortcut icon" type="image/x-icon" href="http://arduino.cc/en/favicon.png">
<link rel='stylesheet' href='arduinoWideRender.css'
type='text/css' />
<!--HeaderText--><style type='text/css'><!--
ul, ol, pre, dl, p { margin-top:0px; margin-bottom:0px; }
code { white-space: nowrap; }
.vspace { margin-top:1.33em; }
.indent { margin-left:40px; }
.outdent { margin-left:40px; text-indent:-40px; }
a.createlinktext { text-decoration:none; border-bottom:1px dotted gray; }
a.createlink { text-decoration:none; position:relative; top:-0.5em;
font-weight:bold; font-size:smaller; border-bottom:none; }
img { border:0px; }
.editconflict { color:green;
font-style:italic; margin-top:1.33em; margin-bottom:1.33em; }
table.markup { border: 2px dotted #ccf; width:90%; }
td.markup1, td.markup2 { padding-left:10px; padding-right:10px; }
td.markup1 { border-bottom: 1px solid #ccf; }
div.faq { margin-left:2em; }
div.faq p.question { margin: 1em 0 0.75em -2em; font-weight:bold; }
div.faq hr { margin-left: -2em; }
.frame
{ border:1px solid #cccccc; padding:4px; background-color:#f9f9f9; }
.lfloat { float:left; margin-right:0.5em; }
.rfloat { float:right; margin-left:0.5em; }
a.varlink { text-decoration:none; }
--></style> <meta name='robots' content='index,follow' />
<meta name="verify-v1" content="TtxFIEJAB6zdJ509wLxjnapQzKAMNm9u0Wj4ho6wxIY=" />
</head>
<body>
<div id="page">
<!--PageHeaderFmt-->
<div id="pageheader">
<div class="title"><a href='http://arduino.cc/en'>Arduino</a></div>
</div>
<!--/PageHeaderFmt-->
<!--PageLeftFmt-->
<div id="pagenav">
<div id="navbar">
<p><a class='wikilink' href='http://arduino.cc/en/Main/Buy'>Buy</a>
<a class='wikilink' href='http://arduino.cc/en/Main/Software'>Download</a>
<a class='wikilink' href='Guide_index.html'>Getting Started</a>
<a class='wikilink' href='http://arduino.cc/en/Tutorial/HomePage'>Learning</a>
<a class='wikilink' href='index.html'>Reference</a>
<a class='wikilink' href='http://arduino.cc/en/Main/Hardware'>Hardware</a>
<a class='wikilink' href='FAQ.html'>FAQ</a>
</p>
<p class='vspace'></p>
</div>
</div>
<!--/PageLeftFmt-->
<div id="pagetext">
<!--PageText-->
<div id='wikitext'>
<p><strong>Reference</strong> &nbsp; <a class='wikilink' href='index.html'>Language</a> | <a class='wikilink' href='Libraries.html'>Libraries</a> | <a class='wikilink' href='Comparison.html'>Comparison</a> | <a class='wikilink' href='Changes.html'>Changes</a>
</p>
<p class='vspace'></p><p><a class='wikilink' href='SD.html'>SD</a> : <em>File</em> class
</p>
<p class='vspace'></p><h2>size()</h2>
<p>Get the size of the file.
</p>
<p class='vspace'></p><h4>Syntax</h4>
<p><em>file</em>.size()
</p>
<p class='vspace'></p><h4>Parameters</h4>
<p><em>file</em>: an instance of the File class (returned by <a class='wikilink' href='SDopen.html'>SD.open()</a>)
</p>
<p class='vspace'></p><h4>Returns</h4>
<p>the size of the file in bytes (<em>unsigned long</em>)
</p>
<p class='vspace'></p><p><a class='wikilink' href='index.html'>Reference Home</a>
</p>
<p class='vspace'></p><p><em>Corrections, suggestions, and new documentation should be posted to the <a class='urllink' href='http://arduino.cc/forum/index.php/board,23.0.html' rel='nofollow'>Forum</a>.</em>
</p>
<p class='vspace'></p><p>The text of the Arduino reference is licensed under a
<a class='urllink' href='http://creativecommons.org/licenses/by-sa/3.0/' rel='nofollow'>Creative Commons Attribution-ShareAlike 3.0 License</a>. Code samples in the reference are released into the public domain.
</p>
</div>
</div>
<!--PageFooterFmt-->
<div id="pagefooter">
&copy;Arduino |
<a href='#'>Edit Page</a> | <a href='#'>Page History</a> | <a href='#' target='_blank'>Printable View</a> | <a href='http://arduino.cc/en/Site/AllRecentChanges'>All Recent Site Changes</a>
</div>
<!--/PageFooterFmt-->
</div>
</body>
</html>

View File

@@ -0,0 +1,115 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>Arduino Reference - FileWrite </title>
<link rel="shortcut icon" type="image/x-icon" href="http://arduino.cc/en/favicon.png">
<link rel='stylesheet' href='arduinoWideRender.css'
type='text/css' />
<!--HeaderText--><style type='text/css'><!--
ul, ol, pre, dl, p { margin-top:0px; margin-bottom:0px; }
code { white-space: nowrap; }
.vspace { margin-top:1.33em; }
.indent { margin-left:40px; }
.outdent { margin-left:40px; text-indent:-40px; }
a.createlinktext { text-decoration:none; border-bottom:1px dotted gray; }
a.createlink { text-decoration:none; position:relative; top:-0.5em;
font-weight:bold; font-size:smaller; border-bottom:none; }
img { border:0px; }
.editconflict { color:green;
font-style:italic; margin-top:1.33em; margin-bottom:1.33em; }
table.markup { border: 2px dotted #ccf; width:90%; }
td.markup1, td.markup2 { padding-left:10px; padding-right:10px; }
td.markup1 { border-bottom: 1px solid #ccf; }
div.faq { margin-left:2em; }
div.faq p.question { margin: 1em 0 0.75em -2em; font-weight:bold; }
div.faq hr { margin-left: -2em; }
.frame
{ border:1px solid #cccccc; padding:4px; background-color:#f9f9f9; }
.lfloat { float:left; margin-right:0.5em; }
.rfloat { float:right; margin-left:0.5em; }
a.varlink { text-decoration:none; }
--></style> <meta name='robots' content='index,follow' />
<meta name="verify-v1" content="TtxFIEJAB6zdJ509wLxjnapQzKAMNm9u0Wj4ho6wxIY=" />
</head>
<body>
<div id="page">
<!--PageHeaderFmt-->
<div id="pageheader">
<div class="title"><a href='http://arduino.cc/en'>Arduino</a></div>
</div>
<!--/PageHeaderFmt-->
<!--PageLeftFmt-->
<div id="pagenav">
<div id="navbar">
<p><a class='wikilink' href='http://arduino.cc/en/Main/Buy'>Buy</a>
<a class='wikilink' href='http://arduino.cc/en/Main/Software'>Download</a>
<a class='wikilink' href='Guide_index.html'>Getting Started</a>
<a class='wikilink' href='http://arduino.cc/en/Tutorial/HomePage'>Learning</a>
<a class='wikilink' href='index.html'>Reference</a>
<a class='wikilink' href='http://arduino.cc/en/Main/Hardware'>Hardware</a>
<a class='wikilink' href='FAQ.html'>FAQ</a>
</p>
<p class='vspace'></p>
</div>
</div>
<!--/PageLeftFmt-->
<div id="pagetext">
<!--PageText-->
<div id='wikitext'>
<p><strong>Reference</strong> &nbsp; <a class='wikilink' href='index.html'>Language</a> | <a class='wikilink' href='Libraries.html'>Libraries</a> | <a class='wikilink' href='Comparison.html'>Comparison</a> | <a class='wikilink' href='Changes.html'>Changes</a>
</p>
<p class='vspace'></p><p><a class='wikilink' href='SD.html'>SD</a> : <em>File</em> class
</p>
<p class='vspace'></p><h2>write()</h2>
<h4>Description</h4>
<p>Write data to the file.
</p>
<p class='vspace'></p><h4>Syntax</h4>
<p><em>file</em>.write(data) <br /><em>file</em>.write(buf, len)
</p>
<p class='vspace'></p><h4>Parameters</h4>
<p><em>file</em>: an instance of the File class (returned by <a class='wikilink' href='SDopen.html'>SD.open()</a>)
</p>
<p class='vspace'></p><p>data: the byte, char, or string (char *) to write
</p>
<p class='vspace'></p><p>buf: an array of characters or bytes
</p>
<p class='vspace'></p><p>len: the number of elements in buf
</p>
<p class='vspace'></p><h4>Returns</h4>
<p>byte<br />write() will return the number of bytes written, though reading that number is optional
</p>
<p class='vspace'></p><h4>See Also</h4>
<ul><li><a class='wikilink' href='FilePrint.html'>print()</a>
</li><li><a class='wikilink' href='FilePrintln.html'>println()</a>
</li><li><a class='wikilink' href='FileRead.html'>read()</a>
</li></ul><p><a class='wikilink' href='index.html'>Reference Home</a>
</p>
<p class='vspace'></p><p><em>Corrections, suggestions, and new documentation should be posted to the <a class='urllink' href='http://arduino.cc/forum/index.php/board,23.0.html' rel='nofollow'>Forum</a>.</em>
</p>
<p class='vspace'></p><p>The text of the Arduino reference is licensed under a
<a class='urllink' href='http://creativecommons.org/licenses/by-sa/3.0/' rel='nofollow'>Creative Commons Attribution-ShareAlike 3.0 License</a>. Code samples in the reference are released into the public domain.
</p>
</div>
</div>
<!--PageFooterFmt-->
<div id="pagefooter">
&copy;Arduino |
<a href='#'>Edit Page</a> | <a href='#'>Page History</a> | <a href='#' target='_blank'>Printable View</a> | <a href='http://arduino.cc/en/Site/AllRecentChanges'>All Recent Site Changes</a>
</div>
<!--/PageFooterFmt-->
</div>
</body>
</html>

View File

@@ -0,0 +1,123 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>Arduino Reference - Float </title>
<link rel="shortcut icon" type="image/x-icon" href="http://arduino.cc/en/favicon.png">
<link rel='stylesheet' href='arduinoWideRender.css'
type='text/css' />
<!--HeaderText--><style type='text/css'><!--
ul, ol, pre, dl, p { margin-top:0px; margin-bottom:0px; }
code { white-space: nowrap; }
.vspace { margin-top:1.33em; }
.indent { margin-left:40px; }
.outdent { margin-left:40px; text-indent:-40px; }
a.createlinktext { text-decoration:none; border-bottom:1px dotted gray; }
a.createlink { text-decoration:none; position:relative; top:-0.5em;
font-weight:bold; font-size:smaller; border-bottom:none; }
img { border:0px; }
.editconflict { color:green;
font-style:italic; margin-top:1.33em; margin-bottom:1.33em; }
table.markup { border: 2px dotted #ccf; width:90%; }
td.markup1, td.markup2 { padding-left:10px; padding-right:10px; }
td.markup1 { border-bottom: 1px solid #ccf; }
div.faq { margin-left:2em; }
div.faq p.question { margin: 1em 0 0.75em -2em; font-weight:bold; }
div.faq hr { margin-left: -2em; }
.frame
{ border:1px solid #cccccc; padding:4px; background-color:#f9f9f9; }
.lfloat { float:left; margin-right:0.5em; }
.rfloat { float:right; margin-left:0.5em; }
a.varlink { text-decoration:none; }
--></style> <meta name='robots' content='index,follow' />
<meta name="verify-v1" content="TtxFIEJAB6zdJ509wLxjnapQzKAMNm9u0Wj4ho6wxIY=" />
</head>
<body>
<div id="page">
<!--PageHeaderFmt-->
<div id="pageheader">
<div class="title"><a href='http://arduino.cc/en'>Arduino</a></div>
</div>
<!--/PageHeaderFmt-->
<!--PageLeftFmt-->
<div id="pagenav">
<div id="navbar">
<p><a class='wikilink' href='http://arduino.cc/en/Main/Buy'>Buy</a>
<a class='wikilink' href='http://arduino.cc/en/Main/Software'>Download</a>
<a class='wikilink' href='Guide_index.html'>Getting Started</a>
<a class='wikilink' href='http://arduino.cc/en/Tutorial/HomePage'>Learning</a>
<a class='wikilink' href='index.html'>Reference</a>
<a class='wikilink' href='http://arduino.cc/en/Main/Hardware'>Hardware</a>
<a class='wikilink' href='FAQ.html'>FAQ</a>
</p>
<p class='vspace'></p>
</div>
</div>
<!--/PageLeftFmt-->
<div id="pagetext">
<!--PageText-->
<div id='wikitext'>
<p><strong>Reference</strong> &nbsp; <a class='wikilink' href='index.html'>Language</a> | <a class='wikilink' href='Libraries.html'>Libraries</a> | <a class='wikilink' href='Comparison.html'>Comparison</a> | <a class='wikilink' href='Changes.html'>Changes</a>
</p>
<p class='vspace'></p><h2>float</h2>
<h4>Description </h4>
<p>Datatype for floating-point numbers, a number that has a decimal point. Floating-point numbers are often used to approximate analog and continuous values because they have greater resolution than integers. Floating-point numbers can be as large as 3.4028235E+38 and as low as -3.4028235E+38. They are stored as 32 bits (4 bytes) of information.
</p>
<p class='vspace'></p><p>Floats have only 6-7 decimal digits of precision. That means the total number of digits, not the number to the right of the decimal point. Unlike other platforms, where you can get more precision by using a double (e.g. up to 15 digits), on the Arduino, double is the same size as float.
</p>
<p class='vspace'></p><p>Floating point numbers are not exact, and may yield strange results when compared. For example <code>6.0 / 3.0</code> may not equal <code>2.0</code>. You should instead check that the absolute value of the difference between the numbers is less than some small number.
</p>
<p class='vspace'></p><p>Floating point math is also much slower than integer math in performing calculations, so should be avoided if, for example, a loop has to run at top speed for a critical timing function. Programmers often go to some lengths to convert floating point calculations to integer math to increase speed.
</p>
<p class='vspace'></p><h4>Examples</h4>
<pre> float myfloat;
float sensorCalbrate = 1.117;
</pre>
<p class='vspace'></p><h4>Syntax</h4>
<pre> float var = val;
</pre>
<p class='vspace'></p><ul><li>var - your float variable name
</li><li>val - the value you assign to that variable
</li></ul><p class='vspace'></p><h4>Example Code</h4>
<pre>
int x;
int y;
float z;
x = 1;
y = x / 2; // y now contains 0, ints can't hold fractions
z = (float)x / 2.0; // z now contains .5 (you have to use 2.0, not 2)
</pre>
<p class='vspace'></p><h4>See Also</h4>
<ul><li><a class='wikilink' href='Int.html'>int</a>
</li><li><a class='wikilink' href='Double.html'>double</a>
</li><li><a class='urllink' href='http://arduino.cc/en/Reference/VariableDeclaration' rel='nofollow'>Variable Declaration</a>
</li></ul><p><a class='wikilink' href='index.html'>Reference Home</a>
</p>
<p class='vspace'></p><p><em>Corrections, suggestions, and new documentation should be posted to the <a class='urllink' href='http://arduino.cc/forum/index.php/board,23.0.html' rel='nofollow'>Forum</a>.</em>
</p>
<p class='vspace'></p><p>The text of the Arduino reference is licensed under a
<a class='urllink' href='http://creativecommons.org/licenses/by-sa/3.0/' rel='nofollow'>Creative Commons Attribution-ShareAlike 3.0 License</a>. Code samples in the reference are released into the public domain.
</p>
</div>
</div>
<!--PageFooterFmt-->
<div id="pagefooter">
&copy;Arduino |
<a href='#'>Edit Page</a> | <a href='#'>Page History</a> | <a href='#' target='_blank'>Printable View</a> | <a href='http://arduino.cc/en/Site/AllRecentChanges'>All Recent Site Changes</a>
</div>
<!--/PageFooterFmt-->
</div>
</body>
</html>

View File

@@ -0,0 +1,108 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>Arduino Reference - FloatCast </title>
<link rel="shortcut icon" type="image/x-icon" href="http://arduino.cc/en/favicon.png">
<link rel='stylesheet' href='arduinoWideRender.css'
type='text/css' />
<!--HeaderText--><style type='text/css'><!--
ul, ol, pre, dl, p { margin-top:0px; margin-bottom:0px; }
code { white-space: nowrap; }
.vspace { margin-top:1.33em; }
.indent { margin-left:40px; }
.outdent { margin-left:40px; text-indent:-40px; }
a.createlinktext { text-decoration:none; border-bottom:1px dotted gray; }
a.createlink { text-decoration:none; position:relative; top:-0.5em;
font-weight:bold; font-size:smaller; border-bottom:none; }
img { border:0px; }
.editconflict { color:green;
font-style:italic; margin-top:1.33em; margin-bottom:1.33em; }
table.markup { border: 2px dotted #ccf; width:90%; }
td.markup1, td.markup2 { padding-left:10px; padding-right:10px; }
td.markup1 { border-bottom: 1px solid #ccf; }
div.faq { margin-left:2em; }
div.faq p.question { margin: 1em 0 0.75em -2em; font-weight:bold; }
div.faq hr { margin-left: -2em; }
.frame
{ border:1px solid #cccccc; padding:4px; background-color:#f9f9f9; }
.lfloat { float:left; margin-right:0.5em; }
.rfloat { float:right; margin-left:0.5em; }
a.varlink { text-decoration:none; }
--></style> <meta name='robots' content='index,follow' />
<meta name="verify-v1" content="TtxFIEJAB6zdJ509wLxjnapQzKAMNm9u0Wj4ho6wxIY=" />
</head>
<body>
<div id="page">
<!--PageHeaderFmt-->
<div id="pageheader">
<div class="title"><a href='http://arduino.cc/en'>Arduino</a></div>
</div>
<!--/PageHeaderFmt-->
<!--PageLeftFmt-->
<div id="pagenav">
<div id="navbar">
<p><a class='wikilink' href='http://arduino.cc/en/Main/Buy'>Buy</a>
<a class='wikilink' href='http://arduino.cc/en/Main/Software'>Download</a>
<a class='wikilink' href='Guide_index.html'>Getting Started</a>
<a class='wikilink' href='http://arduino.cc/en/Tutorial/HomePage'>Learning</a>
<a class='wikilink' href='index.html'>Reference</a>
<a class='wikilink' href='http://arduino.cc/en/Main/Hardware'>Hardware</a>
<a class='wikilink' href='FAQ.html'>FAQ</a>
</p>
<p class='vspace'></p>
</div>
</div>
<!--/PageLeftFmt-->
<div id="pagetext">
<!--PageText-->
<div id='wikitext'>
<p><strong>Reference</strong> &nbsp; <a class='wikilink' href='index.html'>Language</a> | <a class='wikilink' href='Libraries.html'>Libraries</a> | <a class='wikilink' href='Comparison.html'>Comparison</a> | <a class='wikilink' href='Changes.html'>Changes</a>
</p>
<p class='vspace'></p><h2>float()</h2>
<h4>Description</h4>
<p>Converts a value to the <a class='wikilink' href='Float.html'>float</a> data type.
</p>
<p class='vspace'></p><h4>Syntax</h4>
<p>float(x)
</p>
<p class='vspace'></p><h4>Parameters</h4>
<p>x: a value of any type
</p>
<p class='vspace'></p><h4>Returns</h4>
<p>float
</p>
<p class='vspace'></p><h4>Notes</h4>
<p>See the reference for <a class='wikilink' href='Float.html'>float</a> for details about the precision and limitations of floating point numbers on Arduino.
</p>
<p class='vspace'></p><h4>See also</h4>
<ul><li><a class='wikilink' href='Float.html'>float</a>
</li></ul><p><a class='wikilink' href='index.html'>Reference Home</a>
</p>
<p class='vspace'></p><p><em>Corrections, suggestions, and new documentation should be posted to the <a class='urllink' href='http://arduino.cc/forum/index.php/board,23.0.html' rel='nofollow'>Forum</a>.</em>
</p>
<p class='vspace'></p><p>The text of the Arduino reference is licensed under a
<a class='urllink' href='http://creativecommons.org/licenses/by-sa/3.0/' rel='nofollow'>Creative Commons Attribution-ShareAlike 3.0 License</a>. Code samples in the reference are released into the public domain.
</p>
</div>
</div>
<!--PageFooterFmt-->
<div id="pagefooter">
&copy;Arduino |
<a href='#'>Edit Page</a> | <a href='#'>Page History</a> | <a href='#' target='_blank'>Printable View</a> | <a href='http://arduino.cc/en/Site/AllRecentChanges'>All Recent Site Changes</a>
</div>
<!--/PageFooterFmt-->
</div>
</body>
</html>

View File

@@ -0,0 +1,147 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>Arduino Reference - For </title>
<link rel="shortcut icon" type="image/x-icon" href="http://arduino.cc/en/favicon.png">
<link rel='stylesheet' href='arduinoWideRender.css'
type='text/css' />
<!--HeaderText--><style type='text/css'><!--
ul, ol, pre, dl, p { margin-top:0px; margin-bottom:0px; }
code { white-space: nowrap; }
.vspace { margin-top:1.33em; }
.indent { margin-left:40px; }
.outdent { margin-left:40px; text-indent:-40px; }
a.createlinktext { text-decoration:none; border-bottom:1px dotted gray; }
a.createlink { text-decoration:none; position:relative; top:-0.5em;
font-weight:bold; font-size:smaller; border-bottom:none; }
img { border:0px; }
.editconflict { color:green;
font-style:italic; margin-top:1.33em; margin-bottom:1.33em; }
table.markup { border: 2px dotted #ccf; width:90%; }
td.markup1, td.markup2 { padding-left:10px; padding-right:10px; }
td.markup1 { border-bottom: 1px solid #ccf; }
div.faq { margin-left:2em; }
div.faq p.question { margin: 1em 0 0.75em -2em; font-weight:bold; }
div.faq hr { margin-left: -2em; }
.frame
{ border:1px solid #cccccc; padding:4px; background-color:#f9f9f9; }
.lfloat { float:left; margin-right:0.5em; }
.rfloat { float:right; margin-left:0.5em; }
a.varlink { text-decoration:none; }
--></style> <meta name='robots' content='index,follow' />
<meta name="verify-v1" content="TtxFIEJAB6zdJ509wLxjnapQzKAMNm9u0Wj4ho6wxIY=" />
</head>
<body>
<div id="page">
<!--PageHeaderFmt-->
<div id="pageheader">
<div class="title"><a href='http://arduino.cc/en'>Arduino</a></div>
</div>
<!--/PageHeaderFmt-->
<!--PageLeftFmt-->
<div id="pagenav">
<div id="navbar">
<p><a class='wikilink' href='http://arduino.cc/en/Main/Buy'>Buy</a>
<a class='wikilink' href='http://arduino.cc/en/Main/Software'>Download</a>
<a class='wikilink' href='Guide_index.html'>Getting Started</a>
<a class='wikilink' href='http://arduino.cc/en/Tutorial/HomePage'>Learning</a>
<a class='wikilink' href='index.html'>Reference</a>
<a class='wikilink' href='http://arduino.cc/en/Main/Hardware'>Hardware</a>
<a class='wikilink' href='FAQ.html'>FAQ</a>
</p>
<p class='vspace'></p>
</div>
</div>
<!--/PageLeftFmt-->
<div id="pagetext">
<!--PageText-->
<div id='wikitext'>
<p><strong>Reference</strong> &nbsp; <a class='wikilink' href='index.html'>Language</a> | <a class='wikilink' href='Libraries.html'>Libraries</a> | <a class='wikilink' href='Comparison.html'>Comparison</a> | <a class='wikilink' href='Changes.html'>Changes</a>
</p>
<p class='vspace'></p><h2>for statements</h2>
<h4>Desciption</h4>
<p>The <strong>for</strong> statement is used to repeat a block of statements enclosed in curly braces. An increment counter is usually used to increment and terminate the loop. The <strong>for</strong> statement is useful for any repetitive operation, and is often used in combination with arrays to operate on collections of data/pins.
</p>
<p class='vspace'></p><p>There are three parts to the <strong>for</strong> loop header:
</p>
<p class='vspace'></p><p><code><strong>for</strong> (<strong>initialization</strong>;<strong> condition</strong>;<strong> increment</strong>) {</code>
</p>
<p class='vspace'></p><p><code> //statement(s);</code>
</p>
<p class='vspace'></p><p><code>}</code>
</p><div><img height='220px' src='http://arduino.cc/en/uploads/Reference/ForLoopIllustrated.png' alt='' title='' /></div>
<p class='vspace'></p><p>The <strong>initialization</strong> happens first and exactly once. Each time through the loop, the <strong>condition</strong> is tested; if it's true, the statement block, and the <strong>increment</strong> is executed, then the <strong>condition</strong> is tested again. When the <strong>condition</strong> becomes false, the loop ends.
</p>
<p class='vspace'></p><h4>Example</h4>
<pre>
// Dim an LED using a PWM pin
int PWMpin = 10; // LED in series with 470 ohm resistor on pin 10
void setup()
{
// no setup needed
}
void loop()
{
for (int i=0; i &lt;= 255; i++){
analogWrite(PWMpin, i);
delay(10);
}
}
</pre>
<p class='vspace'></p><h4>Coding Tips</h4>
<p>The C <strong>for</strong> loop is much more flexible than <strong>for</strong> loops found in some other computer languages, including BASIC. Any or all of the three header elements may be omitted, although the semicolons are required. Also the statements for initialization, condition, and increment can be any valid C statements with unrelated variables, and use any C datatypes including floats. These types of unusual <strong>for</strong> statements may provide solutions to some rare programming problems.
</p>
<p class='vspace'></p><p>For example, using a multiplication in the increment line will generate a logarithmic progression:<br />
</p><pre>for(int x = 2; x &lt; 100; x = x * 1.5){
println(x);
}
</pre>
<p class='vspace'></p><p>Generates: 2,3,4,6,9,13,19,28,42,63,94
</p>
<p class='vspace'></p><p>Another example, fade an LED up and down with one <strong>for</strong> loop:
</p>
<p class='vspace'></p><pre>void loop()
{
int x = 1;
for (int i = 0; i &gt; -1; i = i + x){
analogWrite(PWMpin, i);
if (i == 255) x = -1; // switch direction at peak
delay(10);
}
}
</pre>
<p class='vspace'></p><h4>See also</h4>
<ul><li><a class='wikilink' href='While.html'>while</a>
</li></ul><p><a class='wikilink' href='index.html'>Reference Home</a>
</p>
<p class='vspace'></p><p><em>Corrections, suggestions, and new documentation should be posted to the <a class='urllink' href='http://arduino.cc/forum/index.php/board,23.0.html' rel='nofollow'>Forum</a>.</em>
</p>
<p class='vspace'></p><p>The text of the Arduino reference is licensed under a
<a class='urllink' href='http://creativecommons.org/licenses/by-sa/3.0/' rel='nofollow'>Creative Commons Attribution-ShareAlike 3.0 License</a>. Code samples in the reference are released into the public domain.
</p>
</div>
</div>
<!--PageFooterFmt-->
<div id="pagefooter">
&copy;Arduino |
<a href='#'>Edit Page</a> | <a href='#'>Page History</a> | <a href='#' target='_blank'>Printable View</a> | <a href='http://arduino.cc/en/Site/AllRecentChanges'>All Recent Site Changes</a>
</div>
<!--/PageFooterFmt-->
</div>
</body>
</html>

View File

@@ -0,0 +1,108 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>Arduino Reference - Fpconstants </title>
<link rel="shortcut icon" type="image/x-icon" href="http://arduino.cc/en/favicon.png">
<link rel='stylesheet' href='arduinoWideRender.css'
type='text/css' />
<!--HeaderText--><style type='text/css'><!--
ul, ol, pre, dl, p { margin-top:0px; margin-bottom:0px; }
code { white-space: nowrap; }
.vspace { margin-top:1.33em; }
.indent { margin-left:40px; }
.outdent { margin-left:40px; text-indent:-40px; }
a.createlinktext { text-decoration:none; border-bottom:1px dotted gray; }
a.createlink { text-decoration:none; position:relative; top:-0.5em;
font-weight:bold; font-size:smaller; border-bottom:none; }
img { border:0px; }
.editconflict { color:green;
font-style:italic; margin-top:1.33em; margin-bottom:1.33em; }
table.markup { border: 2px dotted #ccf; width:90%; }
td.markup1, td.markup2 { padding-left:10px; padding-right:10px; }
td.markup1 { border-bottom: 1px solid #ccf; }
div.faq { margin-left:2em; }
div.faq p.question { margin: 1em 0 0.75em -2em; font-weight:bold; }
div.faq hr { margin-left: -2em; }
.frame
{ border:1px solid #cccccc; padding:4px; background-color:#f9f9f9; }
.lfloat { float:left; margin-right:0.5em; }
.rfloat { float:right; margin-left:0.5em; }
a.varlink { text-decoration:none; }
--></style> <meta name='robots' content='index,follow' />
<meta name="verify-v1" content="TtxFIEJAB6zdJ509wLxjnapQzKAMNm9u0Wj4ho6wxIY=" />
</head>
<body>
<div id="page">
<!--PageHeaderFmt-->
<div id="pageheader">
<div class="title"><a href='http://arduino.cc/en'>Arduino</a></div>
</div>
<!--/PageHeaderFmt-->
<!--PageLeftFmt-->
<div id="pagenav">
<div id="navbar">
<p><a class='wikilink' href='http://arduino.cc/en/Main/Buy'>Buy</a>
<a class='wikilink' href='http://arduino.cc/en/Main/Software'>Download</a>
<a class='wikilink' href='Guide_index.html'>Getting Started</a>
<a class='wikilink' href='http://arduino.cc/en/Tutorial/HomePage'>Learning</a>
<a class='wikilink' href='index.html'>Reference</a>
<a class='wikilink' href='http://arduino.cc/en/Main/Hardware'>Hardware</a>
<a class='wikilink' href='FAQ.html'>FAQ</a>
</p>
<p class='vspace'></p>
</div>
</div>
<!--/PageLeftFmt-->
<div id="pagetext">
<!--PageText-->
<div id='wikitext'>
<p><strong>Reference</strong> &nbsp; <a class='wikilink' href='index.html'>Language</a> | <a class='wikilink' href='Libraries.html'>Libraries</a> | <a class='wikilink' href='Comparison.html'>Comparison</a> | <a class='wikilink' href='Changes.html'>Changes</a>
</p>
<p class='vspace'></p><h2>floating point constants</h2>
<p>Similar to integer constants, floating point constants are used to make code more readable. Floating point constants are swapped at compile time for the value to which the expression evaluates.
</p>
<p class='vspace'></p><p>Examples:
</p>
<p class='vspace'></p><p><code>n = .005; </code>
</p>
<p class='vspace'></p><p>Floating point constants can also be expressed in a variety of scientific notation. 'E' and 'e' are both accepted as valid exponent indicators.
</p>
<p class='vspace'></p><pre>
floating-point evaluates to: also evaluates to:
constant
10.0 10
2.34E5 2.34 * 10^5 234000
67e-12 67.0 * 10^-12 .000000000067
</pre><p><a class='wikilink' href='index.html'>Reference Home</a>
</p>
<p class='vspace'></p><p><em>Corrections, suggestions, and new documentation should be posted to the <a class='urllink' href='http://arduino.cc/forum/index.php/board,23.0.html' rel='nofollow'>Forum</a>.</em>
</p>
<p class='vspace'></p><p>The text of the Arduino reference is licensed under a
<a class='urllink' href='http://creativecommons.org/licenses/by-sa/3.0/' rel='nofollow'>Creative Commons Attribution-ShareAlike 3.0 License</a>. Code samples in the reference are released into the public domain.
</p>
</div>
</div>
<!--PageFooterFmt-->
<div id="pagefooter">
&copy;Arduino |
<a href='#'>Edit Page</a> | <a href='#'>Page History</a> | <a href='#' target='_blank'>Printable View</a> | <a href='http://arduino.cc/en/Site/AllRecentChanges'>All Recent Site Changes</a>
</div>
<!--/PageFooterFmt-->
</div>
</body>
</html>

View File

@@ -0,0 +1,116 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>Arduino Reference - Goto </title>
<link rel="shortcut icon" type="image/x-icon" href="http://arduino.cc/en/favicon.png">
<link rel='stylesheet' href='arduinoWideRender.css'
type='text/css' />
<!--HeaderText--><style type='text/css'><!--
ul, ol, pre, dl, p { margin-top:0px; margin-bottom:0px; }
code { white-space: nowrap; }
.vspace { margin-top:1.33em; }
.indent { margin-left:40px; }
.outdent { margin-left:40px; text-indent:-40px; }
a.createlinktext { text-decoration:none; border-bottom:1px dotted gray; }
a.createlink { text-decoration:none; position:relative; top:-0.5em;
font-weight:bold; font-size:smaller; border-bottom:none; }
img { border:0px; }
.editconflict { color:green;
font-style:italic; margin-top:1.33em; margin-bottom:1.33em; }
table.markup { border: 2px dotted #ccf; width:90%; }
td.markup1, td.markup2 { padding-left:10px; padding-right:10px; }
td.markup1 { border-bottom: 1px solid #ccf; }
div.faq { margin-left:2em; }
div.faq p.question { margin: 1em 0 0.75em -2em; font-weight:bold; }
div.faq hr { margin-left: -2em; }
.frame
{ border:1px solid #cccccc; padding:4px; background-color:#f9f9f9; }
.lfloat { float:left; margin-right:0.5em; }
.rfloat { float:right; margin-left:0.5em; }
a.varlink { text-decoration:none; }
--></style> <meta name='robots' content='index,follow' />
<meta name="verify-v1" content="TtxFIEJAB6zdJ509wLxjnapQzKAMNm9u0Wj4ho6wxIY=" />
</head>
<body>
<div id="page">
<!--PageHeaderFmt-->
<div id="pageheader">
<div class="title"><a href='http://arduino.cc/en'>Arduino</a></div>
</div>
<!--/PageHeaderFmt-->
<!--PageLeftFmt-->
<div id="pagenav">
<div id="navbar">
<p><a class='wikilink' href='http://arduino.cc/en/Main/Buy'>Buy</a>
<a class='wikilink' href='http://arduino.cc/en/Main/Software'>Download</a>
<a class='wikilink' href='Guide_index.html'>Getting Started</a>
<a class='wikilink' href='http://arduino.cc/en/Tutorial/HomePage'>Learning</a>
<a class='wikilink' href='index.html'>Reference</a>
<a class='wikilink' href='http://arduino.cc/en/Main/Hardware'>Hardware</a>
<a class='wikilink' href='FAQ.html'>FAQ</a>
</p>
<p class='vspace'></p>
</div>
</div>
<!--/PageLeftFmt-->
<div id="pagetext">
<!--PageText-->
<div id='wikitext'>
<p><strong>Reference</strong> &nbsp; <a class='wikilink' href='index.html'>Language</a> | <a class='wikilink' href='Libraries.html'>Libraries</a> | <a class='wikilink' href='Comparison.html'>Comparison</a> | <a class='wikilink' href='Changes.html'>Changes</a>
</p>
<p class='vspace'></p><h2>goto</h2>
<p>Transfers program flow to a labeled point in the program
</p>
<p class='vspace'></p><h4>Syntax</h4>
<p>label:
</p>
<p class='vspace'></p><p>goto label; // sends program flow to the label
</p>
<p class='vspace'></p><h4>Tip</h4>
<p>The use of <em>goto</em> is discouraged in C programming, and some authors of C programming books claim that the <em>goto</em> statement is never necessary, but used judiciously, it can simplify certain programs. The reason that many programmers frown upon the use of <em>goto</em> is that with the unrestrained use of <em>goto</em> statements, it is easy to create a program with undefined program flow, which can never be debugged.
</p>
<p class='vspace'></p><p>With that said, there are instances where a goto statement can come in handy, and simplify coding. One of these situations is to break out of deeply nested <em>for</em> loops, or <em>if</em> logic blocks, on a certain condition.
</p>
<p class='vspace'></p><h4>Example</h4>
<pre>
for(byte r = 0; r &lt; 255; r++){
for(byte g = 255; g &gt; -1; g--){
for(byte b = 0; b &lt; 255; b++){
if (analogRead(0) &gt; 250){ goto bailout;}
// more statements ...
}
}
}
bailout:
</pre>
<p class='vspace'></p><p><a class='wikilink' href='index.html'>Reference Home</a>
</p>
<p class='vspace'></p><p><em>Corrections, suggestions, and new documentation should be posted to the <a class='urllink' href='http://arduino.cc/forum/index.php/board,23.0.html' rel='nofollow'>Forum</a>.</em>
</p>
<p class='vspace'></p><p>The text of the Arduino reference is licensed under a
<a class='urllink' href='http://creativecommons.org/licenses/by-sa/3.0/' rel='nofollow'>Creative Commons Attribution-ShareAlike 3.0 License</a>. Code samples in the reference are released into the public domain.
</p>
</div>
</div>
<!--PageFooterFmt-->
<div id="pagefooter">
&copy;Arduino |
<a href='#'>Edit Page</a> | <a href='#'>Page History</a> | <a href='#' target='_blank'>Printable View</a> | <a href='http://arduino.cc/en/Site/AllRecentChanges'>All Recent Site Changes</a>
</div>
<!--/PageFooterFmt-->
</div>
</body>
</html>

View File

@@ -0,0 +1,106 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>Arduino Reference - ArduinoBT </title>
<link rel="shortcut icon" type="image/x-icon" href="http://arduino.cc/en/favicon.png">
<link rel='stylesheet' href='arduinoWideRender.css'
type='text/css' />
<!--HeaderText--><style type='text/css'><!--
ul, ol, pre, dl, p { margin-top:0px; margin-bottom:0px; }
code { white-space: nowrap; }
.vspace { margin-top:1.33em; }
.indent { margin-left:40px; }
.outdent { margin-left:40px; text-indent:-40px; }
a.createlinktext { text-decoration:none; border-bottom:1px dotted gray; }
a.createlink { text-decoration:none; position:relative; top:-0.5em;
font-weight:bold; font-size:smaller; border-bottom:none; }
img { border:0px; }
.editconflict { color:green;
font-style:italic; margin-top:1.33em; margin-bottom:1.33em; }
table.markup { border: 2px dotted #ccf; width:90%; }
td.markup1, td.markup2 { padding-left:10px; padding-right:10px; }
td.markup1 { border-bottom: 1px solid #ccf; }
div.faq { margin-left:2em; }
div.faq p.question { margin: 1em 0 0.75em -2em; font-weight:bold; }
div.faq hr { margin-left: -2em; }
.frame
{ border:1px solid #cccccc; padding:4px; background-color:#f9f9f9; }
.lfloat { float:left; margin-right:0.5em; }
.rfloat { float:right; margin-left:0.5em; }
a.varlink { text-decoration:none; }
--></style> <meta name='robots' content='index,follow' />
<meta name="verify-v1" content="TtxFIEJAB6zdJ509wLxjnapQzKAMNm9u0Wj4ho6wxIY=" />
</head>
<body>
<div id="page">
<!--PageHeaderFmt-->
<div id="pageheader">
<div class="title"><a href='http://arduino.cc/en'>Arduino</a></div>
</div>
<!--/PageHeaderFmt-->
<!--PageLeftFmt-->
<div id="pagenav">
<div id="navbar">
<p><a class='wikilink' href='http://arduino.cc/en/Main/Buy'>Buy</a>
<a class='wikilink' href='http://arduino.cc/en/Main/Software'>Download</a>
<a class='wikilink' href='Guide_index.html'>Getting Started</a>
<a class='wikilink' href='http://arduino.cc/en/Tutorial/HomePage'>Learning</a>
<a class='wikilink' href='index.html'>Reference</a>
<a class='wikilink' href='http://arduino.cc/en/Main/Hardware'>Hardware</a>
<a class='wikilink' href='FAQ.html'>FAQ</a>
</p>
<p class='vspace'></p>
</div>
</div>
<!--/PageLeftFmt-->
<div id="pagetext">
<!--PageText-->
<div id='wikitext'>
<h2><span class='wikiword'>ArduinoBT</span></h2>
<p>The Arduino BT is an Arduino board with built-in bluetooth module, allowing for wireless communication. To get started with the Arduino BT, follow the directions for the Arduino NG on your operating system (<a class='wikilink' href='Guide_Windows.html'>Windows</a>, <a class='wikilink' href='Guide_MacOSX.html'>Mac OS X</a>, <a class='urllink' href='http://www.arduino.cc/playground/Learning/Linux' rel='nofollow'>Linux</a>), with the following modifications:
</p>
<p class='vspace'></p><ul><li>First, pair the Arduino BT with your computer and create a virtual serial port for it. Look for a bluetooth device called <strong>ARDUINOBT</strong> and the pass code is <strong>12345</strong>.
<p class='vspace'></p></li><li>Select <strong>Arduino BT</strong> from the <strong>Tools | Board</strong> menu of the Arduino environment.
</li></ul><p class='vspace'></p><p>When uploading to the Arduino BT, you may need to press the reset button on the board shortly before (or shortly after) clicking upload in the Arduino software.
</p>
<p class='vspace'></p><h3>Information about the Arduino BT</h3>
<p>In most respects, the Arduino BT is similar to the Arduino Diecimila. Here are the main differences of BT board (besides the fact that it communicates over bluetooth instead of USB):
</p>
<p class='vspace'></p><ul><li>The Arduino BT is more fragile and easy to break than a regular Arduino board.
<p class='vspace'></p></li><li><strong>Don't power the board with more than 5.5 volts to the or reverse the polarity (power and ground pins) of your power supply, or you might kill the <span class='wikiword'>ATmega168</span> on the Arduino BT.</strong> The Arduino BT can, however, run with a minimum of 1.2 volts, making it easier to power with batteries.
<p class='vspace'></p></li><li>The microcontroller (an <span class='wikiword'>ATmega168</span>) on the Arduino BT is a physically smaller version of the chip on the USB Arduino boards. You can't remove it, so if you kill it, you need a new Arduino BT.
<p class='vspace'></p></li><li>There are two extra analog inputs on the Arduino BT (8 total). Two of these, however, are not connected to the pin headers on the board; you'll need to solder something to the pads next to the numbers "6" and "7".
<p class='vspace'></p></li><li>Pin 7 is connected to the reset pin of the bluetooth module; <strong>don't use it for anything</strong> (except resetting the module).
</li></ul><p class='vspace'></p><p>For more details, see the <a class='wikilink' href='http://arduino.cc/en/Main/ArduinoBoardBluetooth'>Arduino BT hardware page</a>.
</p>
<p class='vspace'></p><h3>Using the Arduino BT</h3>
<p>The on-board serial communication between the bluetooth module and the Arduino sketch (running on the <span class='wikiword'>ATmega168</span>) needs to be at 115200 baud (i.e. call Serial.begin(115200) in your setup() function). Communication between the bluetooth module and the computer can be at any baud rate.
</p>
<p class='vspace'></p><p>Communication between the BT module and the computer can be temperamental. You might want to open the serial monitor a couple of seconds after resetting the board.
</p>
<p class='vspace'></p><p>The text of the Arduino getting started guide is licensed under a
<a class='urllink' href='http://creativecommons.org/licenses/by-sa/3.0/' rel='nofollow'>Creative Commons Attribution-ShareAlike 3.0 License</a>. Code samples in the guide are released into the public domain.
</p>
</div>
</div>
<!--PageFooterFmt-->
<div id="pagefooter">
&copy;Arduino |
<a href='Guide_ArduinoBT?action=edit.html'>Edit Page</a> | <a href='Guide_ArduinoBT?action=diff.html'>Page History</a> | <a href='Guide_ArduinoBT?action=print.html' target='_blank'>Printable View</a> | <a href='http://arduino.cc/en/Site/AllRecentChanges'>All Recent Site Changes</a>
</div>
<!--/PageFooterFmt-->
</div>
</body>
</html>

View File

@@ -0,0 +1,99 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>Arduino Reference - ArduinoEthernetShield </title>
<link rel="shortcut icon" type="image/x-icon" href="http://arduino.cc/en/favicon.png">
<link rel='stylesheet' href='arduinoWideRender.css'
type='text/css' />
<!--HeaderText--><style type='text/css'><!--
ul, ol, pre, dl, p { margin-top:0px; margin-bottom:0px; }
code { white-space: nowrap; }
.vspace { margin-top:1.33em; }
.indent { margin-left:40px; }
.outdent { margin-left:40px; text-indent:-40px; }
a.createlinktext { text-decoration:none; border-bottom:1px dotted gray; }
a.createlink { text-decoration:none; position:relative; top:-0.5em;
font-weight:bold; font-size:smaller; border-bottom:none; }
img { border:0px; }
.editconflict { color:green;
font-style:italic; margin-top:1.33em; margin-bottom:1.33em; }
table.markup { border: 2px dotted #ccf; width:90%; }
td.markup1, td.markup2 { padding-left:10px; padding-right:10px; }
td.markup1 { border-bottom: 1px solid #ccf; }
div.faq { margin-left:2em; }
div.faq p.question { margin: 1em 0 0.75em -2em; font-weight:bold; }
div.faq hr { margin-left: -2em; }
.frame
{ border:1px solid #cccccc; padding:4px; background-color:#f9f9f9; }
.lfloat { float:left; margin-right:0.5em; }
.rfloat { float:right; margin-left:0.5em; }
a.varlink { text-decoration:none; }
--></style> <meta name='robots' content='index,follow' />
<meta name="verify-v1" content="TtxFIEJAB6zdJ509wLxjnapQzKAMNm9u0Wj4ho6wxIY=" />
</head>
<body>
<div id="page">
<!--PageHeaderFmt-->
<div id="pageheader">
<div class="title"><a href='http://arduino.cc/en'>Arduino</a></div>
</div>
<!--/PageHeaderFmt-->
<!--PageLeftFmt-->
<div id="pagenav">
<div id="navbar">
<p><a class='wikilink' href='http://arduino.cc/en/Main/Buy'>Buy</a>
<a class='wikilink' href='http://arduino.cc/en/Main/Software'>Download</a>
<a class='wikilink' href='Guide_index.html'>Getting Started</a>
<a class='wikilink' href='http://arduino.cc/en/Tutorial/HomePage'>Learning</a>
<a class='wikilink' href='index.html'>Reference</a>
<a class='wikilink' href='http://arduino.cc/en/Main/Hardware'>Hardware</a>
<a class='wikilink' href='FAQ.html'>FAQ</a>
</p>
<p class='vspace'></p>
</div>
</div>
<!--/PageLeftFmt-->
<div id="pagetext">
<!--PageText-->
<div id='wikitext'>
<h2>Arduino Ethernet Shield</h2>
<p>The <a class='wikilink' href='http://arduino.cc/en/Main/ArduinoEthernetShield'>Arduino Ethernet shield</a> allows an Arduino board to connect to the internet using the <a class='wikilink' href='Ethernet.html'>Ethernet library</a> and to read and write an SD card using the <a class='wikilink' href='SD.html'>SD library</a>.
</p>
<p class='vspace'></p><h4>Connecting the Shield</h4>
<div><img height='300' src='http://arduino.cc/en/uploads/Guide/ArduinoWithEthernetShield.jpg' alt='' title='' /></div>
<p class='vspace'></p><p>To use the shield, mount it on top of an Arduino board (e.g. the Uno). To upload sketches to the board, connect it to your computer with a USB cable as you normally would. Once the sketch has been uploaded, you can disconnect the board from your computer and power it with an external power supply.
</p>
<p class='vspace'></p><p>Connect the shield to your computer or a network hub or router using a standard ethernet cable (<span class='wikiword'>CAT5</span> or <span class='wikiword'>CAT6</span> with <span class='wikiword'>RJ45</span> connectors). Connecting to a computer may require the use of a cross-over cable (although many computers, including <a class='urllink' href='http://support.apple.com/kb/HT2274' rel='nofollow'>all recent Macs</a> can do the cross-over internally).
</p>
<p class='vspace'></p><h4>Network Settings</h4>
<p>The shield must be assigned a MAC address and a fixed IP address using the <a class='wikilink' href='EthernetBegin.html'>Ethernet.begin()</a> function. A MAC address is a globally unique identifier for a particular device. Current Ethernet shields come with a sticker indicating the MAC address you should use with them. For older shields without a dedicated MAC address, inventing a random one should work, but don't use the same one for multiple boards. Valid IP addresses depend on the configuration of your network. It is possible to use DHCP to dynamically assign an IP to the shield. Optionally, you can also specify a network gateway and subnet.
</p>
<p class='vspace'></p><h4>SD Card</h4>
<p>The latest revision of the Ethernet Shield includes a micro-SD card slot, which can be interfaced with using the <a class='wikilink' href='SD.html'>SD library</a>.
</p>
<p class='vspace'></p><p>The text of the Arduino getting started guide is licensed under a
<a class='urllink' href='http://creativecommons.org/licenses/by-sa/3.0/' rel='nofollow'>Creative Commons Attribution-ShareAlike 3.0 License</a>. Code samples in the guide are released into the public domain.
</p>
</div>
</div>
<!--PageFooterFmt-->
<div id="pagefooter">
&copy;Arduino |
<a href='Guide_ArduinoEthernetShield?action=edit.html'>Edit Page</a> | <a href='Guide_ArduinoEthernetShield?action=diff.html'>Page History</a> | <a href='Guide_ArduinoEthernetShield?action=print.html' target='_blank'>Printable View</a> | <a href='http://arduino.cc/en/Site/AllRecentChanges'>All Recent Site Changes</a>
</div>
<!--/PageFooterFmt-->
</div>
</body>
</html>

View File

@@ -0,0 +1,104 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>Arduino Reference - ArduinoLilyPad </title>
<link rel="shortcut icon" type="image/x-icon" href="http://arduino.cc/en/favicon.png">
<link rel='stylesheet' href='arduinoWideRender.css'
type='text/css' />
<!--HeaderText--><style type='text/css'><!--
ul, ol, pre, dl, p { margin-top:0px; margin-bottom:0px; }
code { white-space: nowrap; }
.vspace { margin-top:1.33em; }
.indent { margin-left:40px; }
.outdent { margin-left:40px; text-indent:-40px; }
a.createlinktext { text-decoration:none; border-bottom:1px dotted gray; }
a.createlink { text-decoration:none; position:relative; top:-0.5em;
font-weight:bold; font-size:smaller; border-bottom:none; }
img { border:0px; }
.editconflict { color:green;
font-style:italic; margin-top:1.33em; margin-bottom:1.33em; }
table.markup { border: 2px dotted #ccf; width:90%; }
td.markup1, td.markup2 { padding-left:10px; padding-right:10px; }
td.markup1 { border-bottom: 1px solid #ccf; }
div.faq { margin-left:2em; }
div.faq p.question { margin: 1em 0 0.75em -2em; font-weight:bold; }
div.faq hr { margin-left: -2em; }
.frame
{ border:1px solid #cccccc; padding:4px; background-color:#f9f9f9; }
.lfloat { float:left; margin-right:0.5em; }
.rfloat { float:right; margin-left:0.5em; }
a.varlink { text-decoration:none; }
--></style> <meta name='robots' content='index,follow' />
<meta name="verify-v1" content="TtxFIEJAB6zdJ509wLxjnapQzKAMNm9u0Wj4ho6wxIY=" />
</head>
<body>
<div id="page">
<!--PageHeaderFmt-->
<div id="pageheader">
<div class="title"><a href='http://arduino.cc/en'>Arduino</a></div>
</div>
<!--/PageHeaderFmt-->
<!--PageLeftFmt-->
<div id="pagenav">
<div id="navbar">
<p><a class='wikilink' href='http://arduino.cc/en/Main/Buy'>Buy</a>
<a class='wikilink' href='http://arduino.cc/en/Main/Software'>Download</a>
<a class='wikilink' href='Guide_index.html'>Getting Started</a>
<a class='wikilink' href='http://arduino.cc/en/Tutorial/HomePage'>Learning</a>
<a class='wikilink' href='index.html'>Reference</a>
<a class='wikilink' href='http://arduino.cc/en/Main/Hardware'>Hardware</a>
<a class='wikilink' href='FAQ.html'>FAQ</a>
</p>
<p class='vspace'></p>
</div>
</div>
<!--/PageLeftFmt-->
<div id="pagetext">
<!--PageText-->
<div id='wikitext'>
<h2>Guide to the <span class='wikiword'>LilyPad</span> Arduino</h2>
<p>To get started with the <span class='wikiword'>LilyPad</span> Arduino, follow the directions for the Arduino NG on your operating system (<a class='wikilink' href='Guide_Windows.html'>Windows</a>, <a class='wikilink' href='Guide_MacOSX.html'>Mac OS X</a>, <a class='urllink' href='http://www.arduino.cc/playground/Learning/Linux' rel='nofollow'>Linux</a>. Connecting the <span class='wikiword'>LilyPad</span> Arduino is a bit more complicated than a regular Arduino board (<a href='#connecting'>see below</a> for instructions and photos).
</p>
<p class='vspace'></p><p>The <span class='wikiword'>LilyPad</span> Arduino is more <strong>fragile and easy to break</strong> than a regular Arduino board. Don't connect more than 5.5 volts to the + tab or reverse the power and ground pins of your power supply, or you will very likely kill the <span class='wikiword'>ATmega</span> on the <span class='wikiword'>LilyPad</span> Arduino. You can't remove the <span class='wikiword'>ATmega</span>, so if you kill it, you need a new <span class='wikiword'>LilyPad</span>.
</p>
<p class='vspace'></p><p>Note: More information about getting started with the <span class='wikiword'>LilyPad</span> Arduino can be found <a class='urllink' href='http://www.media.mit.edu/~leah/LilyPad' rel='nofollow'>here.</a>
</p>
<p class='vspace'></p><p><a name='connecting' id='connecting'></a>
</p><h3>Connecting the <span class='wikiword'>LilyPad</span> Arduino</h3>
<p>To program the <span class='wikiword'>LilyPad</span> Arduino, you need to connect it to your computer. The <a class='urllink' href='http://www.sparkfun.com/commerce/product_info.php?products_id=8772' rel='nofollow'>SparkFun FTDI Basic Breakout</a> plugs into the 6-pin male header on the newest version of the <span class='wikiword'>LilyPad</span>. Use a USB <span class='wikiword'>MiniB</span> cable to connect the FTDI basic breakout to your computer. You can also use an <a class='urllink' href='http://www.ftdichip.com/Products/EvaluationKits/TTL-232R.htm' rel='nofollow'>FTDI USB-TTL Serial cable</a>.
</p>
<p class='vspace'></p><div><img src='http://arduino.cc/en/uploads/Guide/lilypad_basicbreakout.jpg' alt='' title='' /></div>
<p class='vspace'></p><p>To connect earlier versions of the board or for information on other connection options see the <a class='urllink' href='http://www.media.mit.edu/~leah/LilyPad' rel='nofollow'>LilyPad Arduino tutorial</a> on Leah's website
</p>
<p class='vspace'></p><h3>Sewing the <span class='wikiword'>LilyPad</span> Arduino</h3>
<p>The hole on each tab of the <span class='wikiword'>LilyPad</span> is large enough for a sewing needle to pass through. You can make both electrical and physical connections with stitching in conductive thread. Sew through the holes several times to insure good contact. Here's a picture showing a sewn <span class='wikiword'>LilyPad</span>:
</p>
<p class='vspace'></p><div><img src='http://arduino.cc/en/uploads/Guide/lilypad_sewn.jpg' alt='' title='' /></div>
<p class='vspace'></p><p>See the <a class='urllink' href='http://www.media.mit.edu/~leah/LilyPad' rel='nofollow'>LilyPad Arduino tutorial</a> on Leah's website for more information about building a working wearable. See <a class='urllink' href='http://www.sparkfun.com/commerce/categories.php?c=135' rel='nofollow'>SparkFun</a> for more stitchable modules that you can use with your <span class='wikiword'>LilyPad</span> Arduino.
</p>
<p class='vspace'></p><p>The text of the Arduino getting started guide is licensed under a
<a class='urllink' href='http://creativecommons.org/licenses/by-sa/3.0/' rel='nofollow'>Creative Commons Attribution-ShareAlike 3.0 License</a>. Code samples in the guide are released into the public domain.
</p>
</div>
</div>
<!--PageFooterFmt-->
<div id="pagefooter">
&copy;Arduino |
<a href='Guide_ArduinoLilyPad?action=edit.html'>Edit Page</a> | <a href='Guide_ArduinoLilyPad?action=diff.html'>Page History</a> | <a href='Guide_ArduinoLilyPad?action=print.html' target='_blank'>Printable View</a> | <a href='http://arduino.cc/en/Site/AllRecentChanges'>All Recent Site Changes</a>
</div>
<!--/PageFooterFmt-->
</div>
</body>
</html>

View File

@@ -0,0 +1,129 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>Arduino Reference - ArduinoMini </title>
<link rel="shortcut icon" type="image/x-icon" href="http://arduino.cc/en/favicon.png">
<link rel='stylesheet' href='arduinoWideRender.css'
type='text/css' />
<!--HeaderText--><style type='text/css'><!--
ul, ol, pre, dl, p { margin-top:0px; margin-bottom:0px; }
code { white-space: nowrap; }
.vspace { margin-top:1.33em; }
.indent { margin-left:40px; }
.outdent { margin-left:40px; text-indent:-40px; }
a.createlinktext { text-decoration:none; border-bottom:1px dotted gray; }
a.createlink { text-decoration:none; position:relative; top:-0.5em;
font-weight:bold; font-size:smaller; border-bottom:none; }
img { border:0px; }
.editconflict { color:green;
font-style:italic; margin-top:1.33em; margin-bottom:1.33em; }
table.markup { border: 2px dotted #ccf; width:90%; }
td.markup1, td.markup2 { padding-left:10px; padding-right:10px; }
td.markup1 { border-bottom: 1px solid #ccf; }
div.faq { margin-left:2em; }
div.faq p.question { margin: 1em 0 0.75em -2em; font-weight:bold; }
div.faq hr { margin-left: -2em; }
.frame
{ border:1px solid #cccccc; padding:4px; background-color:#f9f9f9; }
.lfloat { float:left; margin-right:0.5em; }
.rfloat { float:right; margin-left:0.5em; }
a.varlink { text-decoration:none; }
--></style> <meta name='robots' content='index,follow' />
<meta name="verify-v1" content="TtxFIEJAB6zdJ509wLxjnapQzKAMNm9u0Wj4ho6wxIY=" />
</head>
<body>
<div id="page">
<!--PageHeaderFmt-->
<div id="pageheader">
<div class="title"><a href='http://arduino.cc/en'>Arduino</a></div>
</div>
<!--/PageHeaderFmt-->
<!--PageLeftFmt-->
<div id="pagenav">
<div id="navbar">
<p><a class='wikilink' href='http://arduino.cc/en/Main/Buy'>Buy</a>
<a class='wikilink' href='http://arduino.cc/en/Main/Software'>Download</a>
<a class='wikilink' href='Guide_index.html'>Getting Started</a>
<a class='wikilink' href='http://arduino.cc/en/Tutorial/HomePage'>Learning</a>
<a class='wikilink' href='index.html'>Reference</a>
<a class='wikilink' href='http://arduino.cc/en/Main/Hardware'>Hardware</a>
<a class='wikilink' href='FAQ.html'>FAQ</a>
</p>
<p class='vspace'></p>
</div>
</div>
<!--/PageLeftFmt-->
<div id="pagetext">
<!--PageText-->
<div id='wikitext'>
<h2>Guide to the Arduino Mini</h2>
<p>To get started with the Arduino Mini, follow the directions for the regular Arduino on your operating system (<a class='wikilink' href='Guide_Windows.html'>Windows</a>, <a class='wikilink' href='Guide_MacOSX.html'>Mac OS X</a>, <a class='urllink' href='http://www.arduino.cc/playground/Learning/Linux' rel='nofollow'>Linux</a>), with the following modifications:
</p>
<p class='vspace'></p><ul><li>Connecting the Arduino Mini is a bit more complicated than a regular Arduino board (<a href='#connecting'>see below</a> for instructions and photos).
<p class='vspace'></p></li><li>You need to select <strong>Arduino Mini</strong> from the <strong>Tools | Board</strong> menu of the Arduino environment.
<p class='vspace'></p></li><li>To upload a new sketch to the Arduino Mini, you need to press the reset button on the board immediately before pressing the upload button in the Arduino environment.
</li></ul><p class='vspace'></p><h3>Information about the Arduino Mini</h3>
<p>The microcontroller (an <span class='wikiword'>ATmega168</span>) on the Arduino Mini is a physically smaller version of the chip on the USB Arduino boards, with the following small difference:
</p>
<p class='vspace'></p><ul><li>There are two extra analog inputs on the Mini (8 total). Four of these, however, are not connected to the legs that come on the Arduino Mini, requiring you to solder wires to their holes to use them. Two of these unconnected pins are also used by the Wire library (<span class='wikiword'>I2C</span>), meaning that its use will require soldering as well.
</li></ul><p class='vspace'></p><p>Also, the Arduino Mini is more <strong>fragile and easy to break</strong> than a regular Arduino board.
</p>
<p class='vspace'></p><ul><li>Don't connect more than 9 volts to the +9V pin or reverse the power and ground pins of your power supply, or you might kill the <span class='wikiword'>ATmega168</span> on the Arduino Mini.
<p class='vspace'></p></li><li>You can't remove the <span class='wikiword'>ATmega168</span>, so if you kill it, you need a new Mini.
</li></ul><p class='vspace'></p><p><a name='connecting' id='connecting'></a>
</p><h3>Connecting the Arduino Mini</h3>
<p>Here's a diagram of the pin layout of the Arduino Mini:
</p>
<p class='vspace'></p>
<table width='95%' border='0' cellpadding='5' cellspacing='0'><tr><td width='50%' valign='top'>
<p class='vspace'></p><div><img src='http://arduino.cc/en/uploads/Guide/arduino_mini_pinout.png' alt='' title='' /></div>
<p class='vspace'></p><p><em>Mini 03 pinout</em> (compatible with earlier revisions)
</p>
<p class='vspace'></p></td><td width='50%' valign='top'>
<p class='vspace'></p><div><img src='http://arduino.cc/en/uploads/Guide/arduino_mini04_pinout.png' alt='' title='' /></div>
<p class='vspace'></p><p><em>Mini 04 pinout</em> (the ground on the left has moved down one pin)
</p>
<p class='vspace'></p></td></tr></table>
<p class='vspace'></p><p>To use the Arduino Mini, you need to connect:
</p>
<p class='vspace'></p><ul><li>Power. This can be a regulated +5V power source (e.g. from the +5V pin of the Mini USB Adapter or an Arduino NG) connected to the +5V pin of the Arduino Mini. Or, a +9V power source (e.g. a 9 volt battery) connected to the +9V pin of the Arduino Mini.
<p class='vspace'></p></li><li>Ground. One of the ground pins on the Arduino Mini must be connected to ground of the power source.
<p class='vspace'></p></li><li>TX/RX. These pins are used both for uploading new sketches to the board and communicating with a computer or other device.
<p class='vspace'></p></li><li>Reset. Whenever this pin is connected to ground, the Arduino Mini resets. You can wire it to a pushbutton, or connect it to +5V to prevent the Arduino Mini from resetting (except when it loses power). If you leave the reset pin unconnected, the Arduino Mini will reset randomly.
<p class='vspace'></p></li><li>An LED. While not technically necessary, connecting an LED to the Arduino Mini makes it easier to check if it's working. Pin 13 has a 1 KB resistor on it, so you can connect an LED to it directly between it and ground. When using another pin, you will need an external resistor.
</li></ul><p class='vspace'></p><p>You have a few options for connecting the board: the Mini USB Adapter, a regular Arduino board, or your own power supply and USB/Serial adapter.
</p>
<p class='vspace'></p><h4>Connecting the Arduino Mini and Mini USB Adapter</h4>
<p>Here is a photo showing the Arduino Mini connected to the Mini USB adapter. Notice that the reset pin is connected directly to +5V (the orange wire), without a pushbutton. Thus, to reset the Arduino Mini, you will need to unplug and reconnect the USB cable to the Mini USB Adapter, or manually move the orange wire connected to the reset pin from +5V to ground and back.
</p>
<p class='vspace'></p><div><img src='http://arduino.cc/en/uploads/Guide/ArduinoMiniBreadboardPhoto.jpg' alt='' title='' /></div>
<p class='vspace'></p><h4>Connecting the Arduino Mini and a regular Arduino</h4>
<p>Here's a photo of the Arduino Mini connected to an Arduino NG. The NG has its <span class='wikiword'>ATmega8</span> removed and is being used for its USB connection, power source, and reset button. Thus, you can reset the Arduino Mini just by pressing the button on the NG.
</p>
<p class='vspace'></p><div><img src='http://arduino.cc/en/uploads/Guide/ArduinoMiniAndNGBreadboardPhoto.jpg' alt='' title='' /></div>
<p>The text of the Arduino getting started guide is licensed under a
<a class='urllink' href='http://creativecommons.org/licenses/by-sa/3.0/' rel='nofollow'>Creative Commons Attribution-ShareAlike 3.0 License</a>. Code samples in the guide are released into the public domain.
</p>
</div>
</div>
<!--PageFooterFmt-->
<div id="pagefooter">
&copy;Arduino |
<a href='Guide_ArduinoMini?action=edit.html'>Edit Page</a> | <a href='Guide_ArduinoMini?action=diff.html'>Page History</a> | <a href='Guide_ArduinoMini?action=print.html' target='_blank'>Printable View</a> | <a href='http://arduino.cc/en/Site/AllRecentChanges'>All Recent Site Changes</a>
</div>
<!--/PageFooterFmt-->
</div>
</body>
</html>

View File

@@ -0,0 +1,96 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>Arduino Reference - ArduinoNano </title>
<link rel="shortcut icon" type="image/x-icon" href="http://arduino.cc/en/favicon.png">
<link rel='stylesheet' href='arduinoWideRender.css'
type='text/css' />
<!--HeaderText--><style type='text/css'><!--
ul, ol, pre, dl, p { margin-top:0px; margin-bottom:0px; }
code { white-space: nowrap; }
.vspace { margin-top:1.33em; }
.indent { margin-left:40px; }
.outdent { margin-left:40px; text-indent:-40px; }
a.createlinktext { text-decoration:none; border-bottom:1px dotted gray; }
a.createlink { text-decoration:none; position:relative; top:-0.5em;
font-weight:bold; font-size:smaller; border-bottom:none; }
img { border:0px; }
.editconflict { color:green;
font-style:italic; margin-top:1.33em; margin-bottom:1.33em; }
table.markup { border: 2px dotted #ccf; width:90%; }
td.markup1, td.markup2 { padding-left:10px; padding-right:10px; }
td.markup1 { border-bottom: 1px solid #ccf; }
div.faq { margin-left:2em; }
div.faq p.question { margin: 1em 0 0.75em -2em; font-weight:bold; }
div.faq hr { margin-left: -2em; }
.frame
{ border:1px solid #cccccc; padding:4px; background-color:#f9f9f9; }
.lfloat { float:left; margin-right:0.5em; }
.rfloat { float:right; margin-left:0.5em; }
a.varlink { text-decoration:none; }
--></style> <meta name='robots' content='index,follow' />
<meta name="verify-v1" content="TtxFIEJAB6zdJ509wLxjnapQzKAMNm9u0Wj4ho6wxIY=" />
</head>
<body>
<div id="page">
<!--PageHeaderFmt-->
<div id="pageheader">
<div class="title"><a href='http://arduino.cc/en'>Arduino</a></div>
</div>
<!--/PageHeaderFmt-->
<!--PageLeftFmt-->
<div id="pagenav">
<div id="navbar">
<p><a class='wikilink' href='http://arduino.cc/en/Main/Buy'>Buy</a>
<a class='wikilink' href='http://arduino.cc/en/Main/Software'>Download</a>
<a class='wikilink' href='Guide_index.html'>Getting Started</a>
<a class='wikilink' href='http://arduino.cc/en/Tutorial/HomePage'>Learning</a>
<a class='wikilink' href='index.html'>Reference</a>
<a class='wikilink' href='http://arduino.cc/en/Main/Hardware'>Hardware</a>
<a class='wikilink' href='FAQ.html'>FAQ</a>
</p>
<p class='vspace'></p>
</div>
</div>
<!--/PageLeftFmt-->
<div id="pagetext">
<!--PageText-->
<div id='wikitext'>
<h2>Guide to the Arduino Nano</h2>
<div><img src='http://arduino.cc/en/uploads/Guide/ArduinoNanoUSBCable.jpg' alt='' title='' /></div>
<p class='vspace'></p><p><em>Connecting the Arduino Nano 2.2 to a computer with a Mini-B USB cable. Note the blue power LED underneath the board.</em>
</p>
<p class='vspace'></p><p><br clear='all' />
</p>
<p class='vspace'></p><p>To connect the Arduino Nano to your computer, you'll need a Mini-B USB cable. This also provides power to the board, as indicated by the blue LED (which is on the bottom of the Arduino Nano 2.x and the top of the Arduino Nano 3.0).
</p>
<p class='vspace'></p><p>If you have an Arduino Nano 3.0, you'll need to select <strong>Arduino Duemilanove or Nano w/ <span class='wikiword'>ATmega32</span></strong> from the <strong>Tools &gt; Board</strong> menu. If you have an Arduino Nano 2.x, select <strong>Arduino Diecimila, Duemilanove, or Nano w/ <span class='wikiword'>ATmega168</span></strong>. Select the correct serial port selected from the <strong>Tools &gt; Serial Port</strong> menu. Then simply press the upload button in the Arduino environment. The board will automatically reset and the sketch will be uploaded. If you have any problems, see the <a class='wikilink' href='Guide_Troubleshooting#upload.html'>troubleshooting guide</a>.
</p>
<p class='vspace'></p><p>For more details on the Arduino Nano, see the <a class='wikilink' href='http://arduino.cc/en/Main/ArduinoBoardNano'>hardware page</a>.
</p>
<p class='vspace'></p><p>The text of the Arduino getting started guide is licensed under a
<a class='urllink' href='http://creativecommons.org/licenses/by-sa/3.0/' rel='nofollow'>Creative Commons Attribution-ShareAlike 3.0 License</a>. Code samples in the guide are released into the public domain.
</p>
</div>
</div>
<!--PageFooterFmt-->
<div id="pagefooter">
&copy;Arduino |
<a href='Guide_ArduinoNano?action=edit.html'>Edit Page</a> | <a href='Guide_ArduinoNano?action=diff.html'>Page History</a> | <a href='Guide_ArduinoNano?action=print.html' target='_blank'>Printable View</a> | <a href='http://arduino.cc/en/Site/AllRecentChanges'>All Recent Site Changes</a>
</div>
<!--/PageFooterFmt-->
</div>
</body>
</html>

View File

@@ -0,0 +1,119 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>Arduino Reference - ArduinoPro </title>
<link rel="shortcut icon" type="image/x-icon" href="http://arduino.cc/en/favicon.png">
<link rel='stylesheet' href='arduinoWideRender.css'
type='text/css' />
<!--HeaderText--><style type='text/css'><!--
ul, ol, pre, dl, p { margin-top:0px; margin-bottom:0px; }
code { white-space: nowrap; }
.vspace { margin-top:1.33em; }
.indent { margin-left:40px; }
.outdent { margin-left:40px; text-indent:-40px; }
a.createlinktext { text-decoration:none; border-bottom:1px dotted gray; }
a.createlink { text-decoration:none; position:relative; top:-0.5em;
font-weight:bold; font-size:smaller; border-bottom:none; }
img { border:0px; }
.editconflict { color:green;
font-style:italic; margin-top:1.33em; margin-bottom:1.33em; }
table.markup { border: 2px dotted #ccf; width:90%; }
td.markup1, td.markup2 { padding-left:10px; padding-right:10px; }
td.markup1 { border-bottom: 1px solid #ccf; }
div.faq { margin-left:2em; }
div.faq p.question { margin: 1em 0 0.75em -2em; font-weight:bold; }
div.faq hr { margin-left: -2em; }
.frame
{ border:1px solid #cccccc; padding:4px; background-color:#f9f9f9; }
.lfloat { float:left; margin-right:0.5em; }
.rfloat { float:right; margin-left:0.5em; }
a.varlink { text-decoration:none; }
--></style> <meta name='robots' content='index,follow' />
<meta name="verify-v1" content="TtxFIEJAB6zdJ509wLxjnapQzKAMNm9u0Wj4ho6wxIY=" />
</head>
<body>
<div id="page">
<!--PageHeaderFmt-->
<div id="pageheader">
<div class="title"><a href='http://arduino.cc/en'>Arduino</a></div>
</div>
<!--/PageHeaderFmt-->
<!--PageLeftFmt-->
<div id="pagenav">
<div id="navbar">
<p><a class='wikilink' href='http://arduino.cc/en/Main/Buy'>Buy</a>
<a class='wikilink' href='http://arduino.cc/en/Main/Software'>Download</a>
<a class='wikilink' href='Guide_index.html'>Getting Started</a>
<a class='wikilink' href='http://arduino.cc/en/Tutorial/HomePage'>Learning</a>
<a class='wikilink' href='index.html'>Reference</a>
<a class='wikilink' href='http://arduino.cc/en/Main/Hardware'>Hardware</a>
<a class='wikilink' href='FAQ.html'>FAQ</a>
</p>
<p class='vspace'></p>
</div>
</div>
<!--/PageLeftFmt-->
<div id="pagetext">
<!--PageText-->
<div id='wikitext'>
<h2>Arduino Pro</h2>
<p>The Arduino Pro is intended for advanced users who require flexibility and low-cost. It comes with the minimum of components (no on-board USB or pin headers) to keep the cost down. It's a good choice for a board you want to leave embedded in a project. Please note that there are multiple variants of the board which operate at different voltages and clock speeds. You need to know if you have the 3.3V / 8 <span class='wikiword'>MHz</span> version or the 5V / 16 <span class='wikiword'>MHz</span> version.
</p>
<p class='vspace'></p><h3>Uploading Sketches</h3>
<p>The board comes without built-in USB circuitry, so an off-board USB-to-TTL serial convertor must be used to upload sketches. For the 3.3V Arduino Pro boards, this can be a <a class='urllink' href='http://www.ftdichip.com/Products/EvaluationKits/TTL-232R-3V3.htm' rel='nofollow'>FTDI TTL-232R-3V3 USB - TTL Level Serial Converter Cable</a> or the <span class='wikiword'>SparkFun</span> <a class='urllink' href='http://www.sparkfun.com/commerce/product_info.php?products_id=8772' rel='nofollow'>FTDI Basic Breakout Board (3.3V)</a>. For the 5V Arduino Pro boards, use a <a class='urllink' href='http://www.ftdichip.com/Products/EvaluationKits/TTL-232R.htm' rel='nofollow'>TTL-232R USB - TTL Level Serial Converter</a> or the <span class='wikiword'>SparkFun</span> <a class='urllink' href='http://www.sparkfun.com/commerce/product_info.php?products_id=9115' rel='nofollow'>FTDI Basic Breakout Board (5V)</a>. (You can probably also get away with using a 5V USB-to-serial convertor with a 3.3V board and vice-versa, but it's not recommended.)
</p>
<p class='vspace'></p><p>If using the FTDI cable on Windows, you'll need to make one configuration change to enable the auto-reset. With the board connected, open the Device Manager (in Control Panels &gt; System &gt; Hardware), and find the USB Serial Port under Ports. Right-click and select properties, then go to Port Settings &gt; Advanced and check Set RTS on Close under Miscellaneous Options.
</p>
<p class='vspace'></p><p>For the 3.3V versions of the Arduino Pro, select <strong>Arduino Pro or Pro Mini (3.3V, 8 <span class='wikiword'>MHz</span>) w/ <span class='wikiword'>ATmega328</span></strong> or <strong>Arduino Pro or Pro Mini (3.3V, 8 <span class='wikiword'>MHz</span>) w/ <span class='wikiword'>ATmega168</span></strong> from the <strong>Tools &gt; Board</strong> menu (depending on the microcontroller on your board). For the 5V versions of the Arduino Pro, select <strong>Arduino Duemilanove or Nano w/ <span class='wikiword'>ATmega328</span></strong> or <strong>Arduino Diecimila, Duemilanove, or Nano w/ <span class='wikiword'>ATmega168</span></strong>.
</p>
<p class='vspace'></p><p><br clear='all' />
</p>
<p class='vspace'></p><div><img src='http://arduino.cc/en/uploads/Guide/ArduinoProFTDICable.jpg' alt='' title='' /></div>
<p class='vspace'></p><p><em>An Arduino Pro connected to (and powered by) an FTDI USB - TTL Level Serial Converter Cable. The green and yellow wires align with the words "green" and "yellow" written underneath the pins.</em>
</p>
<p class='vspace'></p><p><br clear='all' />
</p>
<p class='vspace'></p><div><img src='http://arduino.cc/en/uploads/Guide/ArduinoProFTDIBreakout.jpg' alt='' title='' /></div>
<p class='vspace'></p><p><em>The Arduino Pro connected to (and powered by) a <span class='wikiword'>SparkFun</span> FTDI Basic Breakout Board (prototype version) and USB Mini-B cable.</em>
</p>
<p class='vspace'></p><p><br clear='all' />
</p>
<p class='vspace'></p><h3>Power</h3>
<p>The external USB-to-TTL serial convertor will power the Arduino Pro, regardless of the position of the switch. To use the board standalone, with no connection to a computer, it can be be powered by a battery or an external power supply (wall wart). You can solder the + and - wires of a battery connector to the corresponding holes on the board. For the 3.3V boards, you can connect a <span class='wikiword'>LiPo</span> battery (with JST connector) to the JST jack. Alternatively, solder a DC power jack into the three large holes on the board, and connect a DC power supply (center positive). When the switch is in the "Batt" position, the board will draw power from an attached battery; when it is in the "Ext." position, power comes from an external power supply. In either position, the board can be powered by the 6-pin USB header.
</p>
<p class='vspace'></p><p><br clear='all' />
</p>
<p class='vspace'></p><div><img src='http://arduino.cc/en/uploads/Guide/ArduinoProBattery.jpg' alt='' title='' /></div>
<p class='vspace'></p><p><em>A 3.3V Arduino Pro powered by a <a class='urllink' href='https://www.sparkfun.com/commerce/product_info.php?products_id=8483' rel='nofollow'>2000 mAh LiPo battery</a> from <span class='wikiword'>SparkFun</span>.</em>
</p>
<p class='vspace'></p><p><br clear='all' />
</p>
<p class='vspace'></p><h3>Connectors</h3>
<p>Any standard 0.1" spaced header can be soldered to the holes on the Arduino Pro. To use every pin requires two 6-pin header and two 8-pin headers. Bare wire can also be soldered directly to the holes. Note that the header spacing is compatible with Arduino shields.
</p>
<p class='vspace'></p><p>The text of the Arduino getting started guide is licensed under a
<a class='urllink' href='http://creativecommons.org/licenses/by-sa/3.0/' rel='nofollow'>Creative Commons Attribution-ShareAlike 3.0 License</a>. Code samples in the guide are released into the public domain.
</p>
</div>
</div>
<!--PageFooterFmt-->
<div id="pagefooter">
&copy;Arduino |
<a href='Guide_ArduinoPro?action=edit.html'>Edit Page</a> | <a href='Guide_ArduinoPro?action=diff.html'>Page History</a> | <a href='Guide_ArduinoPro?action=print.html' target='_blank'>Printable View</a> | <a href='http://arduino.cc/en/Site/AllRecentChanges'>All Recent Site Changes</a>
</div>
<!--/PageFooterFmt-->
</div>
</body>
</html>

View File

@@ -0,0 +1,113 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>Arduino Reference - ArduinoProMini </title>
<link rel="shortcut icon" type="image/x-icon" href="http://arduino.cc/en/favicon.png">
<link rel='stylesheet' href='arduinoWideRender.css'
type='text/css' />
<!--HeaderText--><style type='text/css'><!--
ul, ol, pre, dl, p { margin-top:0px; margin-bottom:0px; }
code { white-space: nowrap; }
.vspace { margin-top:1.33em; }
.indent { margin-left:40px; }
.outdent { margin-left:40px; text-indent:-40px; }
a.createlinktext { text-decoration:none; border-bottom:1px dotted gray; }
a.createlink { text-decoration:none; position:relative; top:-0.5em;
font-weight:bold; font-size:smaller; border-bottom:none; }
img { border:0px; }
.editconflict { color:green;
font-style:italic; margin-top:1.33em; margin-bottom:1.33em; }
table.markup { border: 2px dotted #ccf; width:90%; }
td.markup1, td.markup2 { padding-left:10px; padding-right:10px; }
td.markup1 { border-bottom: 1px solid #ccf; }
div.faq { margin-left:2em; }
div.faq p.question { margin: 1em 0 0.75em -2em; font-weight:bold; }
div.faq hr { margin-left: -2em; }
.frame
{ border:1px solid #cccccc; padding:4px; background-color:#f9f9f9; }
.lfloat { float:left; margin-right:0.5em; }
.rfloat { float:right; margin-left:0.5em; }
a.varlink { text-decoration:none; }
--></style> <meta name='robots' content='index,follow' />
<meta name="verify-v1" content="TtxFIEJAB6zdJ509wLxjnapQzKAMNm9u0Wj4ho6wxIY=" />
</head>
<body>
<div id="page">
<!--PageHeaderFmt-->
<div id="pageheader">
<div class="title"><a href='http://arduino.cc/en'>Arduino</a></div>
</div>
<!--/PageHeaderFmt-->
<!--PageLeftFmt-->
<div id="pagenav">
<div id="navbar">
<p><a class='wikilink' href='http://arduino.cc/en/Main/Buy'>Buy</a>
<a class='wikilink' href='http://arduino.cc/en/Main/Software'>Download</a>
<a class='wikilink' href='Guide_index.html'>Getting Started</a>
<a class='wikilink' href='http://arduino.cc/en/Tutorial/HomePage'>Learning</a>
<a class='wikilink' href='index.html'>Reference</a>
<a class='wikilink' href='http://arduino.cc/en/Main/Hardware'>Hardware</a>
<a class='wikilink' href='FAQ.html'>FAQ</a>
</p>
<p class='vspace'></p>
</div>
</div>
<!--/PageLeftFmt-->
<div id="pagetext">
<!--PageText-->
<div id='wikitext'>
<h2>Arduino Pro Mini</h2>
<p>The Arduino Pro Mini is intended for advanced users who require flexibility, low-cost, and small size. It comes with the minimum of components (no on-board USB or pin headers) to keep the cost down. It's a good choice for a board you want to leave embedded in a project. Please note that there are two versions of the board: one that operates at 5V (like most Arduino boards), and one that operates at 3.3V. Be sure to provide the correct power and use components whose operating voltage matches that of the board.
</p>
<p class='vspace'></p><h3>Uploading Sketches</h3>
<p>The board comes without built-in USB circuitry, so an off-board USB-to-TTL serial convertor must be used to upload sketches. This can be a <a class='urllink' href='http://www.ftdichip.com/Products/EvaluationKits/TTL-232R.htm' rel='nofollow'>FTDI TTL-232R USB - TTL Level Serial Converter Cable</a> for the 5V Arduino Mini Pro), or a <a class='urllink' href='http://www.ftdichip.com/Products/EvaluationKits/TTL-232R-3V3.htm' rel='nofollow'>FTDI TTL-232R-3V3 USB - TTL Level Serial Converter Cable</a> or the <span class='wikiword'>SparkFun</span> <a class='urllink' href='http://www.sparkfun.com/commerce/product_info.php?products_id=8772' rel='nofollow'>FTDI Basic Breakout Board</a> for a 3.3V Arduino Mini Pro.
One quick way to connect these is by inserting a six-pin 0.1" male pin header into the end of the FTDI cable or breakout board, and pressing it against the six hole programming header on the Mini Pro. If, however, you're going to be uploading lots of sketches to your Pro Mini, you'll probably want to solder some pins (male headers) to the holes.
</p>
<p class='vspace'></p><p>If using the FTDI cable on Windows, you'll need to make one configuration change to enable the auto-reset. With the board connected, open the Device Manager (in Control Panels &gt; System &gt; Hardware), and find the USB Serial Port under Ports. Right-click and select properties, then go to Port Settings &gt; Advanced and check Set RTS on Close under Miscellaneous Options.
</p>
<p class='vspace'></p><p>For the 3.3V versions of the Arduino Pro Mini, select <strong>Arduino Pro or Pro Mini (3.3V, 8 <span class='wikiword'>MHz</span>) w/ <span class='wikiword'>ATmega328</span></strong> or <strong>Arduino Pro or Pro Mini (3.3V, 8 <span class='wikiword'>MHz</span>) w/ <span class='wikiword'>ATmega168</span></strong> from the <strong>Tools &gt; Board</strong> menu (depending on the microcontroller on your board). For the 5V versions of the Arduino Pro Mini, select <strong>Arduino Duemilanove or Nano w/ <span class='wikiword'>ATmega328</span></strong> or <strong>Arduino Diecimila, Duemilanove, or Nano w/ <span class='wikiword'>ATmega168</span></strong>.
</p>
<p class='vspace'></p><p><br clear='all' />
</p>
<p class='vspace'></p><div><img src='http://arduino.cc/en/uploads/Guide/ArduinoProMiniFTDICable.jpg' alt='' title='' /></div>
<p class='vspace'></p><p><em>The Arduino Pro Mini connected to (and powered by) an FTDI TTL-232R-3V3 USB - TTL Level Serial Converter Cable. The green and black wires align with the labels "GRN" and "BLK" written next to the holes.</em>
</p>
<p class='vspace'></p><p><br clear='all' />
</p>
<p class='vspace'></p><div><img src='http://arduino.cc/en/uploads/Guide/ArduinoProMiniFTDIBreakout2.jpg' alt='' title='' /></div>
<p class='vspace'></p><p><em>The Arduino Pro Mini connected to (and powered by) a <span class='wikiword'>SparkFun</span> FTDI Basic Breakout Board and USB Mini-B cable. Note that on earlier Pro Mini boards the orientation of the 6-pin header may be reversed; check that the words GRN and BLK align on the Pro Mini and FTDI Basic Breakout.</em>
</p>
<p class='vspace'></p><p><br clear='all' />
</p>
<p class='vspace'></p><h3>Power</h3>
<p>The board can be powered through USB via the six-pin programming header, or from a regulated 5V or 3.3V (depending on the model) supply applied to the VCC pin or an unregulated supply on the RAW pin.
</p>
<p class='vspace'></p><h3>Connectors</h3>
<p>Any standard 0.1" spaced header can be soldered to the holes on the Arduino Pro Mini. To use every pin requires two 12-pin headers, plus a six pin header for programming, if desired. Bare wire can also be soldered directly to the holes.
</p>
<p class='vspace'></p><p>The text of the Arduino getting started guide is licensed under a
<a class='urllink' href='http://creativecommons.org/licenses/by-sa/3.0/' rel='nofollow'>Creative Commons Attribution-ShareAlike 3.0 License</a>. Code samples in the guide are released into the public domain.
</p>
</div>
</div>
<!--PageFooterFmt-->
<div id="pagefooter">
&copy;Arduino |
<a href='Guide_ArduinoProMini?action=edit.html'>Edit Page</a> | <a href='Guide_ArduinoProMini?action=diff.html'>Page History</a> | <a href='Guide_ArduinoProMini?action=print.html' target='_blank'>Printable View</a> | <a href='http://arduino.cc/en/Site/AllRecentChanges'>All Recent Site Changes</a>
</div>
<!--/PageFooterFmt-->
</div>
</body>
</html>

View File

@@ -0,0 +1,174 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>Arduino Reference - ArduinoXbeeShield </title>
<link rel="shortcut icon" type="image/x-icon" href="http://arduino.cc/en/favicon.png">
<link rel='stylesheet' href='arduinoWideRender.css'
type='text/css' />
<!--HeaderText--><style type='text/css'><!--
ul, ol, pre, dl, p { margin-top:0px; margin-bottom:0px; }
code { white-space: nowrap; }
.vspace { margin-top:1.33em; }
.indent { margin-left:40px; }
.outdent { margin-left:40px; text-indent:-40px; }
a.createlinktext { text-decoration:none; border-bottom:1px dotted gray; }
a.createlink { text-decoration:none; position:relative; top:-0.5em;
font-weight:bold; font-size:smaller; border-bottom:none; }
img { border:0px; }
.editconflict { color:green;
font-style:italic; margin-top:1.33em; margin-bottom:1.33em; }
table.markup { border: 2px dotted #ccf; width:90%; }
td.markup1, td.markup2 { padding-left:10px; padding-right:10px; }
td.markup1 { border-bottom: 1px solid #ccf; }
div.faq { margin-left:2em; }
div.faq p.question { margin: 1em 0 0.75em -2em; font-weight:bold; }
div.faq hr { margin-left: -2em; }
.frame
{ border:1px solid #cccccc; padding:4px; background-color:#f9f9f9; }
.lfloat { float:left; margin-right:0.5em; }
.rfloat { float:right; margin-left:0.5em; }
a.varlink { text-decoration:none; }
--></style> <meta name='robots' content='index,follow' />
<meta name="verify-v1" content="TtxFIEJAB6zdJ509wLxjnapQzKAMNm9u0Wj4ho6wxIY=" />
</head>
<body>
<div id="page">
<!--PageHeaderFmt-->
<div id="pageheader">
<div class="title"><a href='http://arduino.cc/en'>Arduino</a></div>
</div>
<!--/PageHeaderFmt-->
<!--PageLeftFmt-->
<div id="pagenav">
<div id="navbar">
<p><a class='wikilink' href='http://arduino.cc/en/Main/Buy'>Buy</a>
<a class='wikilink' href='http://arduino.cc/en/Main/Software'>Download</a>
<a class='wikilink' href='Guide_index.html'>Getting Started</a>
<a class='wikilink' href='http://arduino.cc/en/Tutorial/HomePage'>Learning</a>
<a class='wikilink' href='index.html'>Reference</a>
<a class='wikilink' href='http://arduino.cc/en/Main/Hardware'>Hardware</a>
<a class='wikilink' href='FAQ.html'>FAQ</a>
</p>
<p class='vspace'></p>
</div>
</div>
<!--/PageLeftFmt-->
<div id="pagetext">
<!--PageText-->
<div id='wikitext'>
<h2>Arduino <span class='wikiword'>XBee</span> Shield</h2>
<p>The Arduino Xbee shield allows your Arduino board to communicate wirelessly using Zigbee. It was developed in collaboration with <a class='urllink' href='http://www.libelium.com/' rel='nofollow'>Libelium</a>. This documentation describes the use of the shield with the <span class='wikiword'>XBee</span> 802.15.4 module (sometimes called "Series 1" to distinguish them from the Series 2 modules, although "Series 1" doesn't appear in the official name or product description). For the <span class='wikiword'>XBee</span> <span class='wikiword'>ZNet</span> 2.5 ("Series 2") modules, see <a class='urllink' href='http://www.humboldt.edu/~cm19/XBee%20setup.pdf' rel='nofollow'>this configuration guide</a>.
</p>
<p class='vspace'></p><h3>A Simple Example</h3>
<p>You should be able to get two Arduino boards with Xbee shields talking to each other without any configuration, using just the standard Arduino serial commands (described in the <a class='wikilink' href='index.html'>reference</a>).
</p>
<p class='vspace'></p><p>To upload a sketch to an Arduino board with a Xbee shield, you'll need to put both jumpers on the shield to the "USB" setting (i.e. place them on the two pins closest to the edge of the board) or remove them completely (but be sure not to lose them!). Then, you can upload a sketch normally from the Arduino environment. In this case, upload the <strong>Communication | Physical Pixel</strong> sketch to one of the boards. This sketch instructs the board to turn on the LED attached to pin 13 whenever it receives an 'H' over its serial connection, and turn the LED off when it gets an 'L'. You can test it by connecting to the board with the Arduino serial monitor (be sure it's set at 9600 baud), typing an H, and pressing enter (or clicking send). The LED should turn on. Send an L and the LED should turn off. If nothing happens, you may have an Arduino board that doesn't have a built-in LED on pin 13 (see the <a class='wikilink' href='http://arduino.cc/en/Main/Boards'>board index</a> to check for sure), in this case you'll need to supply your own.
</p>
<p class='vspace'></p><p>Once you've uploaded the Physical Pixel sketch and made sure that it's working, unplug the first Arduino board from the computer. Switch the jumpers to the Xbee setting (i.e. place each on the center pin and the pin farthest from the edge of the board). Now, you need to upload a sketch to the other board. Make sure its jumpers are in the USB setting. Then upload the following sketch to the board:
</p>
<p class='vspace'></p><pre>
void setup()
{
Serial.begin(9600);
}
void loop()
{
Serial.print('H');
delay(1000);
Serial.print('L');
delay(1000);
}
</pre>
<p class='vspace'></p><p>When it's finished uploading, you can check that it's working with the Arduino serial monitor. You should see H's and L's arriving one a second. Turn off the serial monitor and unplug the board. Switch the jumpers to the Xbee setting. Now connect both boards to the computer. After a few seconds, you should see the LED on the first board turn on and off, once a second. (This is the LED on the Arduino board itself, not the one on the Xbee shield, which conveys information about the state of the Xbee module.) If so, congratulations, your Arduino boards are communicating wirelessly. This may not seem that exciting when both boards are connected to the same computer, but if you connect them to different computers (or power them with an external power supply - being sure to switch the power jumper on the Arduino board), they should still be able to communicate.
</p>
<p class='vspace'></p><h3>A Few Notes</h3>
<p>You can use any of the standard Arduino serial commands with the Xbee shield. With the shield's jumpers in the Xbee position, the print and println commands will send data over the Xbee shield and the USB connection (i.e. to other Xbee shields and to the computer at the same time). In this configuration, however, the board will only receive data from the Xbee shield not from the USB connection (you'll need to switch the jumpers to allow the board to receive data from the computer).
</p>
<p class='vspace'></p><p>The Xbee module on the shield is set up to work at 9600 baud by default, so unless you reconfigure it, you'll need to make sure you're passing 9600 to the Serial.begin() command in your sketch.
</p>
<p class='vspace'></p><p>To allow your computer to communicate directly with the Xbee shield, connect it to an Arduino board whose microcontroller has been removed and place its jumpers in the USB configuration. Then you can send data to and receive data from the Xbee module from any terminal program. This allows you, for example, to see the data that the module is receiving from other Xbee shields (e.g. to collect sensor data wirelessly from a number of locations).
</p>
<p class='vspace'></p><h3>Configuring the Xbee Module</h3>
<p>You can configure the Xbee module from code running on the Arduino board or from software on the computer. To configure it from the Arduino board, you'll need to have the jumpers in the Xbee position. To configure it from the computer, you'll need to have the jumpers in the USB configuration and have removed the microncontroller from your Arduino board.
</p>
<p class='vspace'></p><p>To get the module into configuration mode, you need to send it three plus signs: +++ and there needs to be at least one second before and after during which you send no other character to the module. Note that this includes newlines or carriage return characters. Thus, if you're trying to configure the module from the computer, you need to make sure your terminal software is configured to send characters as you type them, without waiting for you to press enter. Otherwise, it will send the plus signs immediately followed by a newline (i.e. you won't get the needed one second delay after the +++). If you successfully enter configuration mode, the module will send back the two characters 'OK', followed by a carriage return.
</p>
<p class='vspace'></p>
<table width="60%"><tr><td width="50%" valign='top'> Send Command
</td><td width="50%" valign='top'> Expected Response
</td></tr><tr><td valign='top'> <code>+++</code>
</td><td valign='top'> <code>OK</code><em>&lt;CR&gt;</em>
</td></tr></table>
<p class='vspace'></p><p>Once in configuration mode, you can send AT commands to the module. Command strings have the form <span class='wikiword'>ATxx</span> (where xx is the name of a setting). To read the current value of the setting, send the command string followed by a carriage return. To write a new value to the setting, send the command string, immediately followed by the new setting (with no spaces or newlines in-between), followed by a carriage return. For example, to read the network ID of the module (which determines which other Xbee modules it will communicate with), use the <em>'ATID</em> command:
</p>
<p class='vspace'></p>
<table width="60%"><tr><td width="50%" valign='top'> Send Command
</td><td width="50%" valign='top'> Expected Response
</td></tr><tr><td valign='top'> <code>ATID</code><em>&lt;enter&gt;</em>
</td><td valign='top'> <code>3332</code><em>&lt;CR&gt;</em>
</td></tr></table>
<p class='vspace'></p><p>To change the network ID of the module:
</p>
<p class='vspace'></p>
<table width="60%"><tr><td width="50%" valign='top'> Send Command
</td><td width="50%" valign='top'> Expected Response
</td></tr><tr><td valign='top'> <code><span class='wikiword'>ATID3331</span></code><em>&lt;enter&gt;</em>
</td><td valign='top'> <code>OK</code><em>&lt;CR&gt;</em>
</td></tr></table>
<p class='vspace'></p><p>Now, check that the setting has taken effect:
</p>
<p class='vspace'></p>
<table width="60%"><tr><td width="50%" valign='top'> Send Command
</td><td width="50%" valign='top'> Expected Response
</td></tr><tr><td valign='top'> <code>ATID</code><em>&lt;enter&gt;</em>
</td><td valign='top'> <code>3331</code><em>&lt;CR&gt;</em>
</td></tr></table>
<p class='vspace'></p><p>Unless you tell the module to write the changes to non-volatile (long-term) memory, they will only be in effect until the module loses power. To save the changes permanently (until you explicitly modify them again), use the <strong>ATWR</strong> command:
</p>
<p class='vspace'></p>
<table width="60%"><tr><td width="50%" valign='top'> Send Command
</td><td width="50%" valign='top'> Expected Response
</td></tr><tr><td valign='top'> <code>ATWR</code><em>&lt;enter&gt;</em>
</td><td valign='top'> <code>OK</code><em>&lt;CR&gt;</em>
</td></tr></table>
<p class='vspace'></p><p>To reset the module to the factory settings, use the <strong>ATRE</strong> command:
</p>
<p class='vspace'></p>
<table width="60%"><tr><td width="50%" valign='top'> Send Command
</td><td width="50%" valign='top'> Expected Response
</td></tr><tr><td valign='top'> <code>ATRE</code><em>&lt;enter&gt;</em>
</td><td valign='top'> <code>OK</code><em>&lt;CR&gt;</em>
</td></tr></table>
<p class='vspace'></p><p>Note that like the other commands, the reset will not be permanent unless you follow it with the <strong>ATWR</strong> comamand.
</p>
<p class='vspace'></p><h3>References</h3>
<p>For more information, see: the <a class='wikilink' href='http://arduino.cc/en/Main/ArduinoXbeeShield'>hardware page</a> for the Xbee shield, the <a class='urllink' href='http://www.squidbee.org/' rel='nofollow'>Libelium SquidBee wiki</a>, and the <a class='urllink' href='http://www.maxstream.net/products/xbee/xbee-oem-rf-module-zigbee.php' rel='nofollow'>MaxStream Xbee page</a>.
</p>
<p class='vspace'></p><p>The text of the Arduino getting started guide is licensed under a
<a class='urllink' href='http://creativecommons.org/licenses/by-sa/3.0/' rel='nofollow'>Creative Commons Attribution-ShareAlike 3.0 License</a>. Code samples in the guide are released into the public domain.
</p>
</div>
</div>
<!--PageFooterFmt-->
<div id="pagefooter">
&copy;Arduino |
<a href='Guide_ArduinoXbeeShield?action=edit.html'>Edit Page</a> | <a href='Guide_ArduinoXbeeShield?action=diff.html'>Page History</a> | <a href='Guide_ArduinoXbeeShield?action=print.html' target='_blank'>Printable View</a> | <a href='http://arduino.cc/en/Site/AllRecentChanges'>All Recent Site Changes</a>
</div>
<!--/PageFooterFmt-->
</div>
</body>
</html>

View File

@@ -0,0 +1,209 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>Arduino Reference - Environment </title>
<link rel="shortcut icon" type="image/x-icon" href="http://arduino.cc/en/favicon.png">
<link rel='stylesheet' href='arduinoWideRender.css'
type='text/css' />
<!--HeaderText--><style type='text/css'><!--
ul, ol, pre, dl, p { margin-top:0px; margin-bottom:0px; }
code { white-space: nowrap; }
.vspace { margin-top:1.33em; }
.indent { margin-left:40px; }
.outdent { margin-left:40px; text-indent:-40px; }
a.createlinktext { text-decoration:none; border-bottom:1px dotted gray; }
a.createlink { text-decoration:none; position:relative; top:-0.5em;
font-weight:bold; font-size:smaller; border-bottom:none; }
img { border:0px; }
.editconflict { color:green;
font-style:italic; margin-top:1.33em; margin-bottom:1.33em; }
table.markup { border: 2px dotted #ccf; width:90%; }
td.markup1, td.markup2 { padding-left:10px; padding-right:10px; }
td.markup1 { border-bottom: 1px solid #ccf; }
div.faq { margin-left:2em; }
div.faq p.question { margin: 1em 0 0.75em -2em; font-weight:bold; }
div.faq hr { margin-left: -2em; }
.frame
{ border:1px solid #cccccc; padding:4px; background-color:#f9f9f9; }
.lfloat { float:left; margin-right:0.5em; }
.rfloat { float:right; margin-left:0.5em; }
a.varlink { text-decoration:none; }
--></style> <meta name='robots' content='index,follow' />
<meta name="verify-v1" content="TtxFIEJAB6zdJ509wLxjnapQzKAMNm9u0Wj4ho6wxIY=" />
</head>
<body>
<div id="page">
<!--PageHeaderFmt-->
<div id="pageheader">
<div class="title"><a href='http://arduino.cc/en'>Arduino</a></div>
</div>
<!--/PageHeaderFmt-->
<!--PageLeftFmt-->
<div id="pagenav">
<div id="navbar">
<p><a class='wikilink' href='http://arduino.cc/en/Main/Buy'>Buy</a>
<a class='wikilink' href='http://arduino.cc/en/Main/Software'>Download</a>
<a class='wikilink' href='Guide_index.html'>Getting Started</a>
<a class='wikilink' href='http://arduino.cc/en/Tutorial/HomePage'>Learning</a>
<a class='wikilink' href='index.html'>Reference</a>
<a class='wikilink' href='http://arduino.cc/en/Main/Hardware'>Hardware</a>
<a class='wikilink' href='FAQ.html'>FAQ</a>
</p>
<p class='vspace'></p>
</div>
</div>
<!--/PageLeftFmt-->
<div id="pagetext">
<!--PageText-->
<div id='wikitext'>
<h2>Arduino Development Environment</h2>
<p>The Arduino development environment contains a text editor for writing code, a message area, a text console, a toolbar with buttons for common functions, and a series of menus. It connects to the Arduino hardware to upload programs and communicate with them.
</p>
<p class='vspace'></p><p>Software written using Arduino are called <strong>sketches</strong>. These sketches are written in the text editor. Sketches are saved with the file extension .ino. It has features for cutting/pasting and for searching/replacing text. The message area gives feedback while saving and exporting and also displays errors. The console displays text output by the Arduino environment including complete error messages and other information. The bottom righthand corner of the window displays the current board and serial port. The toolbar buttons allow you to verify and upload programs, create, open, and save sketches, and open the serial monitor:
</p>
<p class='vspace'></p><p><strong>NB: Versions of the IDE prior to 1.0 saved sketches with the extension .pde. It is possible to open these files with version 1.0, you will be prompted to save the sketch with the .ino extension on save.</strong>
</p>
<p class='vspace'></p>
<p class='vspace'></p><table width='100%'><tr><td width='40' valign='top'>
<p class='vspace'></p><div><img src='http://arduino.cc/en/uploads/Guide/play.png' alt='' title='' /></div>
<p class='vspace'></p></td><td valign='top'>
<p class='vspace'></p><p><em>Verify</em> <br clear='all' /> Checks your code for errors.
</p>
<p class='vspace'></p></td></tr><tr><td valign='top'>
<p class='vspace'></p><div><img src='http://arduino.cc/en/uploads/Guide/export.png' alt='' title='' /></div>
<p class='vspace'></p></td><td valign='top'>
<p class='vspace'></p><p><em>Upload</em> <br clear='all' /> Compiles your code and uploads it to the Arduino I/O board. See <a href='#uploading'>uploading</a> below for details.
</p>
<p class='vspace'></p><p>Note: If you are using an external programmer, you can hold down the "shift" key on your computer when using this icon. The text will change to "Upload using Programmer"
</p>
<p class='vspace'></p></td></tr><tr><td valign='top'>
<p class='vspace'></p><div><img src='http://arduino.cc/en/uploads/Guide/new.png' alt='' title='' /></div>
<p class='vspace'></p></td><td valign='top'>
<p class='vspace'></p><p><em>New</em> <br clear='all' /> Creates a new sketch.
</p>
<p class='vspace'></p></td></tr><tr><td valign='top'>
<p class='vspace'></p><div><img src='http://arduino.cc/en/uploads/Guide/open.png' alt='' title='' /></div>
<p class='vspace'></p></td><td valign='top'>
<p class='vspace'></p><p><em>Open</em> <br clear='all' /> Presents a menu of all the sketches in your sketchbook. Clicking one will open it within the current window.
</p>
<p class='vspace'></p><p>Note: due to a bug in Java, this menu doesn't scroll; if you need to open a sketch late in the list, use the <strong>File | Sketchbook</strong> menu instead.
</p>
<p class='vspace'></p></td></tr><tr><td valign='top'>
<p class='vspace'></p><div><img src='http://arduino.cc/en/uploads/Guide/save.png' alt='' title='' /></div>
<p class='vspace'></p></td><td valign='top'>
<p class='vspace'></p><p><em>Save</em> <br clear='all' /> Saves your sketch.
</p>
<p class='vspace'></p></td></tr><tr><td valign='top'>
<p class='vspace'></p><div><img src='http://arduino.cc/en/uploads/Guide/serial_monitor.png' alt='' title='' /></div>
<p class='vspace'></p></td><td valign='top'>
<p class='vspace'></p><p><em>Serial Monitor</em> <br clear='all' /> Opens the <a href='#serialmonitor'>serial monitor</a>.
</p>
<p class='vspace'></p></td></tr></table>
<p class='vspace'></p><p>Additional commands are found within the five menus: <strong>File</strong>, <strong>Edit</strong>, <strong>Sketch</strong>, <strong>Tools</strong>, <strong>Help</strong>. The menus are context sensitive which means only those items relevant to the work currently being carried out are available.
</p>
<p class='vspace'></p><h4>Edit</h4>
<ul><li><em>Copy for Forum</em> <br clear='all' /> Copies the code of your sketch to the clipboard in a form suitable for posting to the forum, complete with syntax coloring.
<p class='vspace'></p></li><li><em>Copy as HTML</em> <br clear='all' /> Copies the code of your sketch to the clipboard as HTML, suitable for embedding in web pages.
</li></ul><p class='vspace'></p><h4>Sketch</h4>
<ul><li><em>Verify/Compile</em> <br clear='all' /> Checks your sketch for errors.
<p class='vspace'></p></li><li><em>Show Sketch Folder</em> <br clear='all' /> Opens the current sketch folder.
<p class='vspace'></p></li><li><em>Add File...</em> <br clear='all' /> Adds a source file to the sketch (it will be copied from its current location). The new file appears in a new tab in the sketch window. Files can be removed from the sketch using the tab menu.
<p class='vspace'></p></li><li><em>Import Library</em> <br clear='all' /> Adds a library to your sketch by inserting #include statements at the code of your code. For more details, see <a href='#libraries'>libraries</a> below.
</li></ul><p class='vspace'></p><h4>Tools</h4>
<ul><li><em>Auto Format</em> <br clear='all' /> This formats your code nicely: i.e. indents it so that opening and closing curly braces line up, and that the statements instead curly braces are indented more.
<p class='vspace'></p></li><li><em>Archive Sketch</em> <br clear='all' /> Archives a copy of the current sketch in .zip format. The archive is placed in the same directory as the sketch.
<p class='vspace'></p></li><li><em>Board</em> <br clear='all' /> Select the board that you're using. See below for <a href='#boards'>descriptions of the various boards</a>.
<p class='vspace'></p></li><li><em>Serial Port</em> <br clear='all' /> This menu contains all the serial devices (real or virtual) on your machine. It should automatically refresh every time you open the top-level tools menu.
<p class='vspace'></p></li><li><em>Programmer</em> <br clear='all' /> For selecting a harware programmer when programming a board or chip and not using the onboard USB-serial connection. Normally you won't need this, but if you're <a class='wikilink' href='http://arduino.cc/en/Tutorial/Bootloader'>burning a bootloader</a> to a new microcontroller, you will use this.
<p class='vspace'></p></li><li><em>Burn Bootloader</em> <br clear='all' /> The items in this menu allow you to burn a <a class='wikilink' href='http://arduino.cc/en/Tutorial/Bootloader'>bootloader</a> onto the microcontroller on an Arduino board. This is not required for normal use of an Arduino board but is useful if you purchase a new <span class='wikiword'>ATmega</span> microcontroller (which normally come without a bootloader). Ensure that you've selected the correct board from the <strong>Boards</strong> menu before burning the bootloader.
</li></ul><p class='vspace'></p><p><a name='sketchbook' id='sketchbook'></a>
</p><h3>Sketchbook</h3>
<p>The Arduino environment uses the concept of a sketchbook: a standard place to store your programs (or sketches). The sketches in your sketchbook can be opened from the <strong>File &gt; Sketchbook</strong> menu or from the <strong>Open</strong> button on the toolbar. The first time you run the Arduino software, it will automatically create a directory for your sketchbook. You can view or change the location of the sketchbook location from with the <strong>Preferences</strong> dialog.
</p>
<p class='vspace'></p><p>'''Beginning with version 1.0, files are saved with a .ino file extension. Previous versions use the .pde extension. You may still open .pde named files in version 1.0 and later, the software will automatically rename the extension to .ino.
</p>
<p class='vspace'></p><h3>Tabs, Multiple Files, and Compilation</h3>
<p>Allows you to manage sketches with more than one file (each of which appears in its own tab). These can be normal Arduino code files (no extension), C files (.c extension), C++ files (.cpp), or header files (.h).
</p>
<p class='vspace'></p><p><a name='uploading' id='uploading'></a>
</p><h3>Uploading</h3>
<p>Before uploading your sketch, you need to select the correct items from the <strong>Tools &gt; Board</strong> and <strong>Tools &gt; Serial Port</strong> menus. The <a href='#boards'>boards</a> are described below. On the Mac, the serial port is probably something like <strong>/dev/tty.usbmodem241</strong> (for an Uno or Mega2560 or Leonardo) or <strong>/dev/tty.usbserial-1B1</strong> (for a Duemilanove or earlier USB board), or <strong>/dev/<span class='wikiword'>tty.USA19QW1b1P1</span>.1</strong> (for a serial board connected with a Keyspan USB-to-Serial adapter). On Windows, it's probably <strong><span class='wikiword'>COM1</span></strong> or <strong><span class='wikiword'>COM2</span></strong> (for a serial board) or <strong><span class='wikiword'>COM4</span></strong>, <strong><span class='wikiword'>COM5</span></strong>, <strong><span class='wikiword'>COM7</span></strong>, or higher (for a USB board) - to find out, you look for USB serial device in the ports section of the Windows Device Manager. On Linux, it should be <strong>/dev/ttyUSB0</strong>, <strong>/dev/ttyUSB1</strong> or similar.
</p>
<p class='vspace'></p><p>Once you've selected the correct serial port and board, press the upload button in the toolbar or select the <strong>Upload</strong> item from the <strong>File</strong> menu. Current Arduino boards will reset automatically and begin the upload. With older boards (pre-Diecimila) that lack auto-reset, you'll need to press the reset button on the board just before starting the upload. On most boards, you'll see the RX and TX <span class='wikiword'>LEDs</span> blink as the sketch is uploaded. The Arduino environment will display a message when the upload is complete, or show an error.
</p>
<p class='vspace'></p><p>When you upload a sketch, you're using the Arduino <strong>bootloader</strong>, a small program that has been loaded on to the microcontroller on your board. It allows you to upload code without using any additional hardware. The bootloader is active for a few seconds when the board resets; then it starts whichever sketch was most recently uploaded to the microcontroller. The bootloader will blink the on-board (pin 13) LED when it starts (i.e. when the board resets).
</p>
<p class='vspace'></p><p><a name='libraries' id='libraries'></a>
</p><h3>Libraries</h3>
<p>Libraries provide extra functionality for use in sketches, e.g. working with hardware or manipulating data. To use a library in a sketch, select it from the <strong>Sketch &gt; Import Library</strong> menu. This will insert one or more <strong>#include</strong> statements at the top of the sketch and compile the library with your sketch. Because libraries are uploaded to the board with your sketch, they increase the amount of space it takes up. If a sketch no longer needs a library, simply delete its <strong>#include</strong> statements from the top of your code.
</p>
<p class='vspace'></p><p>There is a <a class='wikilink' href='Libraries.html'>list of libraries</a> in the reference. Some libraries are included with the Arduino software. Others can be downloaded from a variety of sources. To install these third-party libraries, create a directory called <strong>libraries</strong> within your <a href='#sketchbook'>sketchbook directory</a>. Then unzip the library there. For example, to install the <span class='wikiword'>DateTime</span> library, its files should be in the <strong>/<span class='wikiword'>libraries/DateTime</span></strong> sub-folder of your sketchbook folder.
</p>
<p class='vspace'></p><p>To write your own library, see <a class='wikilink' href='http://arduino.cc/en/Hacking/LibraryTutorial'>this tutorial</a>.
</p>
<p class='vspace'></p><p><a name='thirdpartyhardware' id='thirdpartyhardware'></a>
</p><h3>Third-Party Hardware</h3>
<p>Support for third-party hardware can be added to the <strong>hardware</strong> directory of your sketchbook directory. Platforms installed there may include board definitions (which appear in the board menu), core libraries, bootloaders, and programmer definitions. To install, create the <strong>hardware</strong> directory, then unzip the third-party platform into its own sub-directory. (Don't use "arduino" as the sub-directory name or you'll override the built-in Arduino platform.) To uninstall, simply delete its directory.
</p>
<p class='vspace'></p><p>For details on creating packages for third-party hardware, see the <a class='urllink' href='http://code.google.com/p/arduino/wiki/Platforms' rel='nofollow'>platforms page</a> on the Arduino Google Code developers site.
</p>
<p class='vspace'></p><p><a name='serialmonitor' id='serialmonitor'></a>
</p><h3>Serial Monitor</h3>
<p>Displays serial data being sent from the Arduino board (USB or serial board). To send data to the board, enter text and click on the "send" button or press enter. Choose the baud rate from the drop-down that matches the rate passed to <strong>Serial.begin</strong> in your sketch. Note that on Mac or Linux, the Arduino board will reset (rerun your sketch from the beginning) when you connect with the serial monitor.
</p>
<p class='vspace'></p><p>You can also talk to the board from Processing, Flash, <span class='wikiword'>MaxMSP</span>, etc (see the <a class='urllink' href='http://www.arduino.cc/playground/Main/Interfacing' rel='nofollow'>interfacing page</a> for details).
</p>
<p class='vspace'></p><p><a name='preferences' id='preferences'></a>
</p><h3>Preferences</h3>
<p>Some preferences can be set in the preferences dialog (found under the <strong>Arduino</strong> menu on the Mac, or <strong>File</strong> on Windows and Linux). The rest can be found in the preferences file, whose location is shown in the preference dialog.
</p>
<p class='vspace'></p><p><a name='boards' id='boards'></a>
</p><h3>Boards</h3>
<p>The board selection has two effects: it sets the parameters (e.g. CPU speed and baud rate) used when compiling and uploading sketches; and sets and the file and fuse settings used by the burn bootloader command. Some of the board definitions differ only in the latter, so even if you've been uploading successfully with a particular selection you'll want to check it before burning the bootloader.
</p>
<p class='vspace'></p><ul><li><em>Arduino Uno</em> <br clear='all' /> An <span class='wikiword'>ATmega328</span> running at 16 <span class='wikiword'>MHz</span> with auto-reset, using the optiboot bootloader (115200 baud, 0.5 KB).
<p class='vspace'></p></li><li><em>Arduino Duemilanove or Nano w/ <span class='wikiword'>ATmega328</span></em> <br clear='all' /> An <span class='wikiword'>ATmega328</span> running at 16 <span class='wikiword'>MHz</span> with auto-reset.
<p class='vspace'></p></li><li><em>Arduino Diecimila, Duemilanove, or Nano w/ <span class='wikiword'>ATmega168</span></em> <br clear='all' /> An <span class='wikiword'>ATmega168</span> running at 16 <span class='wikiword'>MHz</span> with auto-reset. Compilation and upload is equivalent to Arduino NG or older w/ <span class='wikiword'>ATmega168</span>, but the bootloader burned has a faster timeout (and blinks the pin 13 LED only once on reset).
<p class='vspace'></p></li><li><em>Arduino Mega 2560</em> <br clear='all' /> An <span class='wikiword'>ATmega2560</span> running at 16 <span class='wikiword'>MHz</span> with auto-reset, using an stk500v2 bootloader.
<p class='vspace'></p></li><li><em>Arduino Mega (<span class='wikiword'>ATmega1280</span>)</em> <br clear='all' /> An <span class='wikiword'>ATmega1280</span> running at 16 <span class='wikiword'>MHz</span> with auto-reset.
<p class='vspace'></p></li><li><em>Arduino Mini</em> <br clear='all' /> Equivalent to Arduino NG or older w/ <span class='wikiword'>ATmega168</span> (i.e. an <span class='wikiword'>ATmega168</span> running at 16 <span class='wikiword'>MHz</span> without auto-reset).
<p class='vspace'></p></li><li><em>Arduino Ethernet</em> <br clear='all' /> Equivalent to Arduino UNO with an Ethernet shield.
<p class='vspace'></p></li><li><em>Arduino Fio</em> <br clear='all' /> An <span class='wikiword'>ATmega328</span> running at 8 <span class='wikiword'>MHz</span> with auto-reset. Equivalent to Arduino Pro or Pro Mini (3.3V, 8 <span class='wikiword'>MHz</span>) w/ <span class='wikiword'>ATmega328</span>.
<p class='vspace'></p></li><li><em>Arduino BT w/ <span class='wikiword'>ATmega328</span></em> <br clear='all' /> <span class='wikiword'>ATmega328</span> running at 16 <span class='wikiword'>MHz</span>. The bootloader burned (4 KB) includes codes to initialize the on-board bluetooth module.
<p class='vspace'></p></li><li><em>Arduino BT w/ <span class='wikiword'>ATmega168</span></em> <br clear='all' /> <span class='wikiword'>ATmega168</span> running at 16 <span class='wikiword'>MHz</span>. The bootloader burned includes codes to initialize the on-board bluetooth module.
<p class='vspace'></p></li><li><em><span class='wikiword'>LilyPad</span> Arduino w/ <span class='wikiword'>ATmega328</span></em> <br clear='all' /> An <span class='wikiword'>ATmega328</span> running at 8 <span class='wikiword'>MHz</span> (3.3V) with auto-reset. Equivalent to Arduino Pro or Pro Mini (3.3V, 8 <span class='wikiword'>MHz</span>) w/ <span class='wikiword'>ATmega328</span>.
<p class='vspace'></p></li><li><em><span class='wikiword'>LilyPad</span> Arduino w/ <span class='wikiword'>ATmega168</span></em> <br clear='all' /> An <span class='wikiword'>ATmega168</span> running at 8 <span class='wikiword'>MHz</span>. Compilation and upload is equivalent to the Arduino Pro or Pro Mini (8 <span class='wikiword'>MHz</span>) w/ <span class='wikiword'>ATmega168</span>. The bootloader burned, however, has a slower timeout (and blinks the pin 13 LED three times on reset) because the original versions of the <span class='wikiword'>LilyPad</span> didn't support auto-reset. They also didn't include an external clock, so the burn bootloader command configures the fuses of <span class='wikiword'>ATmega168</span> for an internal 8 <span class='wikiword'>MHz</span> clock. <br clear='all' /> <br clear='all' /> If you have a recent version of the <span class='wikiword'>LilyPad</span>, (w/ a 6-pin programming header), you'll want to select Arduino Pro or Pro Mini (8 <span class='wikiword'>MHz</span>) w/ <span class='wikiword'>ATmega168</span> before burning the bootloader.
<p class='vspace'></p></li><li><em>Arduino Pro or Pro Mini (5V, 16 <span class='wikiword'>MHz</span>) w/ <span class='wikiword'>ATmega328</span></em> <br clear='all' /> An <span class='wikiword'>ATmega328</span> running at 16 <span class='wikiword'>MHz</span> with auto-reset. Equivalent to Arduino Duemilanove or Nano w/ <span class='wikiword'>ATmega328</span>.
<p class='vspace'></p></li><li><em>Arduino Pro or Pro Mini (5V, 16 <span class='wikiword'>MHz</span>) w/ <span class='wikiword'>ATmega168</span></em> <br clear='all' /> An <span class='wikiword'>ATmega168</span> running at 16 <span class='wikiword'>MHz</span> with auto-reset. Equivalent to Arduino Diecimila, Duemilanove, or Nano w/ <span class='wikiword'>ATmega168</span>.
<p class='vspace'></p></li><li><em>Arduino Diecimila, Duemilanove, or Nano w/ <span class='wikiword'>ATmega168</span></em> <br clear='all' /> An <span class='wikiword'>ATmega168</span> running at 16 <span class='wikiword'>MHz</span> with auto-reset. Compilation and upload is equivalent to Arduino NG or older w/ <span class='wikiword'>ATmega168</span>, but the bootloader burned has a faster timeout (and blinks the pin 13 LED only once on reset). Also used for the 16 <span class='wikiword'>MHz</span> (5V) versions of the Arduino Pro and Pro Mini with an <span class='wikiword'>ATmega168</span>.
<p class='vspace'></p></li><li><em>Arduino Pro or Pro Mini (3.3V, 8 <span class='wikiword'>MHz</span>) w/ <span class='wikiword'>ATmega328</span></em> <br clear='all' /> An <span class='wikiword'>ATmega328</span> running at 8 <span class='wikiword'>MHz</span> (3.3V) with auto-reset. Equivalent to <span class='wikiword'>LilyPad</span> Arduino w/ <span class='wikiword'>ATmega328</span>.
<p class='vspace'></p></li><li><em>Arduino Pro or Pro Mini (3.3V, 8 <span class='wikiword'>MHz</span>) w/ <span class='wikiword'>ATmega168</span></em> <br clear='all' /> An <span class='wikiword'>ATmega168</span> running at 8 <span class='wikiword'>MHz</span> (3.3V) with auto-reset.
<p class='vspace'></p></li><li><em>Arduino NG or older w/ <span class='wikiword'>ATmega168</span></em> <br clear='all' /> An <span class='wikiword'>ATmega168</span> running at 16 <span class='wikiword'>MHz</span> <em>without</em> auto-reset. Compilation and upload is equivalent to Arduino Diecimila or Duemilanove w/ <span class='wikiword'>ATmega168</span>, but the bootloader burned has a slower timeout (and blinks the pin 13 LED three times on reset).
<p class='vspace'></p></li><li><em>Arduino NG or older w/ <span class='wikiword'>ATmega8</span></em> <br clear='all' /> An <span class='wikiword'>ATmega8</span> running at 16 <span class='wikiword'>MHz</span> <em>without</em> auto-reset.
</li></ul><p class='vspace'></p><p>For instructions on installing support for other boards, see <a href='#thirdpartyhardware'>third-party hardware</a> above.
The text of the Arduino getting started guide is licensed under a
<a class='urllink' href='http://creativecommons.org/licenses/by-sa/3.0/' rel='nofollow'>Creative Commons Attribution-ShareAlike 3.0 License</a>. Code samples in the guide are released into the public domain.
</p>
</div>
</div>
<!--PageFooterFmt-->
<div id="pagefooter">
&copy;Arduino |
<a href='Guide_Environment?action=edit.html'>Edit Page</a> | <a href='Guide_Environment?action=diff.html'>Page History</a> | <a href='Guide_Environment?action=print.html' target='_blank'>Printable View</a> | <a href='http://arduino.cc/en/Site/AllRecentChanges'>All Recent Site Changes</a>
</div>
<!--/PageFooterFmt-->
</div>
</body>
</html>

Some files were not shown because too many files have changed in this diff Show More