aboutsummaryrefslogtreecommitdiffstats
path: root/docs/source/lang/api/digitalread.rst
diff options
context:
space:
mode:
Diffstat (limited to 'docs/source/lang/api/digitalread.rst')
-rw-r--r--docs/source/lang/api/digitalread.rst51
1 files changed, 51 insertions, 0 deletions
diff --git a/docs/source/lang/api/digitalread.rst b/docs/source/lang/api/digitalread.rst
new file mode 100644
index 0000000..03ccd7f
--- /dev/null
+++ b/docs/source/lang/api/digitalread.rst
@@ -0,0 +1,51 @@
+.. highlight:: cpp
+
+.. _lang-digitalread:
+
+digitalRead()
+=============
+
+Reads the value from a specified digital pin, either :ref:`HIGH
+<lang-constants-high>` or :ref:`LOW <lang-constants-low>`.
+
+Library Documentation
+---------------------
+
+.. doxygenfunction:: digitalRead
+
+Discussion
+----------
+
+If the pin isn't connected to anything, ``digitalRead()`` can return
+either HIGH or LOW (and this will change in a way that seems random).
+
+Example
+-------
+
+The following example turns the LED on or off when the button is pressed::
+
+ void setup() {
+ pinMode(BOARD_LED_PIN, OUTPUT);
+ pinMode(BOARD_BUTTON_PIN, INPUT);
+ }
+
+ void loop() {
+ int val = digitalRead(BOARD_BUTTON_PIN); // reads the input pin
+ togglePin(BOARD_LED_PIN);
+ }
+
+Arduino Compatibility
+---------------------
+
+The Maple version of ``digitalRead()`` is compatible with Arduino.
+
+See Also
+--------
+
+- :ref:`BOARD_BUTTON_PIN <lang-board-values-but>`
+- :ref:`lang-isButtonPressed`
+- :ref:`lang-pinmode`
+- :ref:`lang-digitalWrite`
+- :ref:`lang-togglepin`
+
+.. include:: /arduino-cc-attribution.txt