aboutsummaryrefslogtreecommitdiffstats
path: root/source/lang/loop.rst
diff options
context:
space:
mode:
authorMarti Bolivar <mbolivar@mit.edu>2010-11-28 11:23:33 -0500
committerMarti Bolivar <mbolivar@mit.edu>2010-11-28 11:23:33 -0500
commitd9cbd78e29d42e70bb46641dd43ee0772c8c975f (patch)
tree80a67cba4468dbcd89b3cd23ad56695b1f146c66 /source/lang/loop.rst
parent546b34076d230b617ba86defb6b90cd934b01878 (diff)
downloadlibrambutan-d9cbd78e29d42e70bb46641dd43ee0772c8c975f.tar.gz
librambutan-d9cbd78e29d42e70bb46641dd43ee0772c8c975f.zip
reorganized all the arduino/ docs into a lang/ subdirectory since
they're properly CC attributed now.
Diffstat (limited to 'source/lang/loop.rst')
-rw-r--r--source/lang/loop.rst45
1 files changed, 45 insertions, 0 deletions
diff --git a/source/lang/loop.rst b/source/lang/loop.rst
new file mode 100644
index 0000000..d8f6183
--- /dev/null
+++ b/source/lang/loop.rst
@@ -0,0 +1,45 @@
+.. highlight:: cpp
+
+.. _lang-loop:
+
+loop()
+======
+
+After creating a :ref:`setup() <lang-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 = 38;
+
+ // setup initializes serial and the button pin
+ void setup() {
+ SerialUSB.begin();
+ pinMode(buttonPin, INPUT);
+ }
+
+ // 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() <lang-setup>`
+
+
+.. include:: cc-attribution.txt