aboutsummaryrefslogtreecommitdiffstats
path: root/source/lang/api/waitforbuttonpress.rst
diff options
context:
space:
mode:
authorMarti Bolivar <mbolivar@leaflabs.com>2011-05-25 01:53:29 -0400
committerMarti Bolivar <mbolivar@leaflabs.com>2011-05-26 02:42:07 -0400
commit376e1c98b4e1d34c216dba4b8c320b0c083a7a1c (patch)
treede53df0e9dcb37b5a7f988e7234fd002d9c59fad /source/lang/api/waitforbuttonpress.rst
parent6432343170fc6f7d24e75220948c5d4c38394476 (diff)
downloadlibrambutan-376e1c98b4e1d34c216dba4b8c320b0c083a7a1c.tar.gz
librambutan-376e1c98b4e1d34c216dba4b8c320b0c083a7a1c.zip
Docs: Move toggleLED() and waitForButtonPress() examples.
These two examples from board-values.rst really belong in the documentation for the functions they reference.
Diffstat (limited to 'source/lang/api/waitforbuttonpress.rst')
-rw-r--r--source/lang/api/waitforbuttonpress.rst28
1 files changed, 26 insertions, 2 deletions
diff --git a/source/lang/api/waitforbuttonpress.rst b/source/lang/api/waitforbuttonpress.rst
index a5bd45c..0e0fbaf 100644
--- a/source/lang/api/waitforbuttonpress.rst
+++ b/source/lang/api/waitforbuttonpress.rst
@@ -1,16 +1,40 @@
+.. highlight:: cpp
+
.. _lang-waitforbuttonpress:
waitForButtonPress()
====================
-Wait for the board's built-in button (labeled BUT on the silkscreen)
-to be pressed, possibly with timeout.
+Wait for the board's built-in button to be pressed, possibly with
+timeout. The button is labeled "BUT" on the board's silkscreen. Its
+pin number is the constant :ref:`BOARD_BUTTON_PIN
+<lang-board-values-but>`.
Library Documentation
---------------------
.. doxygenfunction:: waitForButtonPress
+
+Example
+-------
+
+.. _lang-waitforbuttonpress-example:
+
+This example sets up the board's button pin as an input, then prints a
+message very time the button is pressed.
+
+::
+
+ void setup() {
+ pinMode(BOARD_BUTTON_PIN, INPUT);
+ }
+
+ void loop() {
+ waitForButtonPress();
+ SerialUSB.println("You pressed the button!");
+ }
+
See Also
--------