aboutsummaryrefslogtreecommitdiffstats
path: root/source/lang/api/waitforbuttonpress.rst
blob: 0e0fbafa204bb70fadee6894487667297f7e9ea1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
.. highlight:: cpp

.. _lang-waitforbuttonpress:

waitForButtonPress()
====================

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
--------

- :ref:`Board-specific values <lang-board-values>`
- :ref:`BOARD_BUTTON_PIN <lang-board-values-but>`
- :ref:`lang-isbuttonpressed`