aboutsummaryrefslogtreecommitdiffstats
path: root/source/arduino/booleanvariables.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
commit85c1c72db022bba891868afd3375e39dbe245701 (patch)
tree9d86a3db825667362a8c89a98a205586015aec94 /source/arduino/booleanvariables.rst
parentabcfcc62cc62dfc088d30d5a6b6c36d6c89f7b07 (diff)
downloadlibrambutan-85c1c72db022bba891868afd3375e39dbe245701.tar.gz
librambutan-85c1c72db022bba891868afd3375e39dbe245701.zip
initial check-in of arduino docs in RST format (converted using wget+pandoc)
Diffstat (limited to 'source/arduino/booleanvariables.rst')
-rw-r--r--source/arduino/booleanvariables.rst53
1 files changed, 53 insertions, 0 deletions
diff --git a/source/arduino/booleanvariables.rst b/source/arduino/booleanvariables.rst
new file mode 100644
index 0000000..3bbe72a
--- /dev/null
+++ b/source/arduino/booleanvariables.rst
@@ -0,0 +1,53 @@
+.. _arduino-booleanvariables:
+
+boolean
+=======
+
+A **boolean** holds one of two values,
+`true <http://arduino.cc/en/Reference/Constants>`_ or
+`false <http://arduino.cc/en/Reference/Constants>`_. (Each boolean
+variable occupies one byte of memory.)
+
+
+
+Example
+-------
+
+::
+
+ int LEDpin = 5; // LED on pin 5
+ int switchPin = 13; // momentary switch on 13, other side connected to ground
+
+ boolean running = false;
+
+ void setup()
+ {
+ pinMode(LEDpin, OUTPUT);
+ pinMode(switchPin, INPUT);
+ digitalWrite(switchPin, HIGH); // turn on pullup resistor
+ }
+
+ void loop()
+ {
+ if (digitalRead(switchPin) == LOW)
+ { // switch is pressed - pullup keeps pin high normally
+ delay(100); // delay to debounce switch
+ running = !running; // toggle running variable
+ digitalWrite(LEDpin, running) // indicate via LED
+ }
+ }
+
+
+
+
+
+
+See also
+--------
+
+
+- `constants <http://arduino.cc/en/Reference/Constants>`_
+- `boolean operators <http://arduino.cc/en/Reference/Boolean>`_
+- `Variable Declaration <http://arduino.cc/en/Reference/VariableDeclaration>`_
+
+