diff options
author | Hanna Mendes Levitin <hanna@anomaly-3.local> | 2010-12-01 03:37:07 -0600 |
---|---|---|
committer | Hanna Mendes Levitin <hanna@anomaly-3.local> | 2010-12-01 03:37:07 -0600 |
commit | a0549b4a15a7093f990fffa4bc1d2d52ec1c16e2 (patch) | |
tree | 9c6383570be6d045db4d8942ca3137fc3cb5b8a0 /docs/source/lang/api/loop.rst | |
parent | 3b7f16dba295da3a0071564ac284c25dc56e6b18 (diff) | |
download | librambutan-a0549b4a15a7093f990fffa4bc1d2d52ec1c16e2.tar.gz librambutan-a0549b4a15a7093f990fffa4bc1d2d52ec1c16e2.zip |
docs, now with style
Diffstat (limited to 'docs/source/lang/api/loop.rst')
-rw-r--r-- | docs/source/lang/api/loop.rst | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/docs/source/lang/api/loop.rst b/docs/source/lang/api/loop.rst new file mode 100644 index 0000000..d8f6183 --- /dev/null +++ b/docs/source/lang/api/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 |