aboutsummaryrefslogtreecommitdiffstats
path: root/docs/source/lang/pinmode.rst
diff options
context:
space:
mode:
Diffstat (limited to 'docs/source/lang/pinmode.rst')
-rw-r--r--docs/source/lang/pinmode.rst76
1 files changed, 76 insertions, 0 deletions
diff --git a/docs/source/lang/pinmode.rst b/docs/source/lang/pinmode.rst
new file mode 100644
index 0000000..aed23d6
--- /dev/null
+++ b/docs/source/lang/pinmode.rst
@@ -0,0 +1,76 @@
+.. highlight:: cpp
+
+.. _lang-pinmode:
+
+pinMode()
+=========
+
+.. contents:: Contents
+ :local:
+
+Library Documentation
+---------------------
+
+.. doxygenfunction:: pinMode
+
+.. doxygenenum:: WiringPinMode
+
+Discussion
+----------
+
+pinMode() is usually called within :ref:`lang-setup` in order to
+configure a pin for a certain usage (although it may be called
+anywhere).
+
+
+Example
+-------
+
+ ::
+
+
+ int ledPin = 13; // LED connected to digital pin 13
+
+ void setup()
+ {
+ pinMode(ledPin, OUTPUT); // sets the digital pin as output
+ }
+
+ void loop()
+ {
+ digitalWrite(ledPin, HIGH); // sets the LED on
+ delay(1000); // waits for a second
+ digitalWrite(ledPin, LOW); // sets the LED off
+ delay(1000); // waits for a second
+ }
+
+
+
+Arduino Compatibility
+---------------------
+
+The libmaple implementation of pinMode() supports OUTPUT and INPUT
+modes with a meaning identical to that of the Arduino function.
+
+INPUT_ANALOG and PWM modes were added because the Maple does not
+distinguish between analog and digital pins the same way the Arduino
+does. Unlike the Arduino, you **must call pinMode**\ () to set up a pin
+for these purposes before a call to, e.g., :ref:`lang-analogRead`.
+In practice, this should only add a few lines of pinMode() calls to
+your :ref:`lang-setup` function.
+
+OUTPUT_OPEN_DRAIN, INPUT_PULLUP, INPUT_PULLDOWN, and PWM_OPEN_DRAIN
+modes represent functionality not currently available on Arduino
+boards.
+
+See also
+--------
+
+- :ref:`lang-constants`
+- :ref:`lang-digitalwrite`
+- :ref:`lang-digitalread`
+- Maple :ref:`GPIO <gpio>` reference page
+
+
+
+.. include:: cc-attribution.txt