aboutsummaryrefslogtreecommitdiffstats
path: root/docs/source/arduino/else.rst
diff options
context:
space:
mode:
authorMarti Bolivar <mbolivar@mit.edu>2010-10-20 06:46:52 -0400
committerMarti Bolivar <mbolivar@mit.edu>2010-10-20 06:46:52 -0400
commit22ff1db8a76c7047b61a424ae1fa5f43697fcb34 (patch)
treebf722c8a5a6bd40e0b33fc4a425e0e5b8b9f4216 /docs/source/arduino/else.rst
parentbac6548fe90b0721e191d68df2677beb4b15f60a (diff)
downloadlibrambutan-22ff1db8a76c7047b61a424ae1fa5f43697fcb34.tar.gz
librambutan-22ff1db8a76c7047b61a424ae1fa5f43697fcb34.zip
initial check-in of arduino docs in RST format (converted using wget+pandoc)
Diffstat (limited to 'docs/source/arduino/else.rst')
-rw-r--r--docs/source/arduino/else.rst73
1 files changed, 73 insertions, 0 deletions
diff --git a/docs/source/arduino/else.rst b/docs/source/arduino/else.rst
new file mode 100644
index 0000000..f278a0d
--- /dev/null
+++ b/docs/source/arduino/else.rst
@@ -0,0 +1,73 @@
+.. _arduino-else:
+
+if / else
+=========
+
+**if/else** allows greater control over the flow of code than the
+basic **if** statement, by allowing multiple tests to be grouped
+together. For example, an analog input could be tested and one
+action taken if the input was less than 500, and another action
+taken if the input was 500 or greater. The code would look like
+this:
+
+
+
+::
+
+ if (pinFiveInput < 500)
+ {
+ // action A
+ }
+ else
+ {
+ // action B
+ }
+
+
+
+**else** can proceed another **if** test, so that multiple,
+mutually exclusive tests can be run at the same time.
+
+
+
+Each test will proceed to the next one until a true test is
+encountered. When a true test is found, its associated block of
+code is run, and the program then skips to the line following the
+entire if/else construction. If no test proves to be true, the
+default **else** block is executed, if one is present, and sets the
+default behavior.
+
+
+
+Note that an **else if** block may be used with or without a
+terminating **else** block and vice versa. An unlimited number of
+such **else if** branches is allowed.
+
+
+
+::
+
+ if (pinFiveInput < 500)
+ {
+ // do Thing A
+ }
+ else if (pinFiveInput >= 1000)
+ {
+ // do Thing B
+ }
+ else
+ {
+ // do Thing C
+ }
+
+Another way to express branching, mutually exclusive tests, is with
+the `switch case <http://arduino.cc/en/Reference/SwitchCase>`_
+statement.
+
+
+
+See also:
+---------
+
+`switch case <http://arduino.cc/en/Reference/SwitchCase>`_
+