aboutsummaryrefslogtreecommitdiffstats
path: root/source/arduino/loop.rst
diff options
context:
space:
mode:
authorMarti Bolivar <mbolivar@mit.edu>2010-10-25 21:15:28 -0400
committerMarti Bolivar <mbolivar@mit.edu>2010-11-17 12:44:28 -0500
commit2d429e75ce69e77f8c95490ac03881ec9aa0354a (patch)
treea3b810a6c75625b07a4b976e5d1e319c60e19a6b /source/arduino/loop.rst
parent30ac55d80c18e93f9c39a6dd850c10f9e7fd92ac (diff)
downloadlibrambutan-2d429e75ce69e77f8c95490ac03881ec9aa0354a.tar.gz
librambutan-2d429e75ce69e77f8c95490ac03881ec9aa0354a.zip
arduino language reference nearing completion, properly CC-BY-SA 3.0 attributed
Diffstat (limited to 'source/arduino/loop.rst')
-rw-r--r--source/arduino/loop.rst49
1 files changed, 26 insertions, 23 deletions
diff --git a/source/arduino/loop.rst b/source/arduino/loop.rst
index 165b7b0..b558edf 100644
--- a/source/arduino/loop.rst
+++ b/source/arduino/loop.rst
@@ -1,39 +1,42 @@
+.. highlight:: cpp
+
.. _arduino-loop:
loop()
======
-After creating a setup() function, which initializes and sets the
-initial values, the loop() function does precisely what its name
-suggests, and loops consecutively, allowing your program to change
-and respond. Use it to actively control the Arduino board.
-
-
+After creating a :ref:`setup() <arduino-setup>` function, which
+initializes your sketch, the ``loop()`` function gets called
+repeatedly, allowing your program to change and respond. Use it to
+actively control your Maple board.
Example
-~~~~~~~
+-------
::
-
- int buttonPin = 3;
-
+
+ int buttonPin = 38;
+
// setup initializes serial and the button pin
- void setup()
- {
- beginSerial(9600);
+ void setup() {
+ SerialUSB.begin();
pinMode(buttonPin, INPUT);
}
-
- // loop checks the button pin each time,
- // and will send serial if it is pressed
- void loop()
- {
- if (digitalRead(buttonPin) == HIGH)
- serialWrite('H');
- else
- serialWrite('L');
-
+
+ // loop() checks the button pin each time it executes,
+ // and will print 'H' if it is pressed, 'L' otherwise
+ void loop() {
+ if (digitalRead(buttonPin) == HIGH) {
+ SerialUSB.println('H');
+ } else {
+ SerialUSB.println('L');
+ }
+
delay(1000);
}
+See Also
+--------
+
+- :ref:`setup() <arduino-setup>`