aboutsummaryrefslogtreecommitdiffstats
path: root/docs/source/arduino
diff options
context:
space:
mode:
Diffstat (limited to 'docs/source/arduino')
-rw-r--r--docs/source/arduino/assignment.rst13
-rw-r--r--docs/source/arduino/attachinterrupt.rst69
2 files changed, 31 insertions, 51 deletions
diff --git a/docs/source/arduino/assignment.rst b/docs/source/arduino/assignment.rst
index 8b851e8..1c790bb 100644
--- a/docs/source/arduino/assignment.rst
+++ b/docs/source/arduino/assignment.rst
@@ -11,7 +11,7 @@ the left of the equal sign.
The single equal sign in the C++ programming language is called the
assignment operator. It has a different meaning than in algebra
-class where it indicated an equation or equality. The assignment
+class, where it indicated an equation or equality. The assignment
operator tells the microcontroller to evaluate whatever value or
expression is on the right side of the equal sign, and store it in
the variable to the left of the equal sign [#fgross]_.
@@ -23,7 +23,7 @@ Example
::
- int sensVal; // declare an integer variable named sensVal
+ int sensVal; // declare an integer variable named sensVal
senVal = analogRead(0); // store the (digitized) input voltage at analog pin 0 in SensVal
@@ -56,8 +56,9 @@ See Also
.. rubric:: Footnotes
- Experienced C++ programmers know this to be an oversimplification
- of what happens when the variable on the left hand side is an
- object. See Richard Gillam's wonderful and scary `The Anatomy of
- the Assignment Operator
+.. [#fgross] Experienced C++ programmers know this to be an
+ oversimplification of what happens when the variable on the left
+ hand side is an object. See Richard Gillam's wonderful and scary
+ `The Anatomy of the Assignment Operator
<http://icu-project.org/docs/papers/cpp_report/the_anatomy_of_the_assignment_operator.html>`_
+ for more information.
diff --git a/docs/source/arduino/attachinterrupt.rst b/docs/source/arduino/attachinterrupt.rst
index 27a1d77..189141b 100644
--- a/docs/source/arduino/attachinterrupt.rst
+++ b/docs/source/arduino/attachinterrupt.rst
@@ -1,59 +1,30 @@
+.. highlight:: cpp
+
.. _arduino-attachinterrupt:
attachInterrupt(interrupt, function, mode)
==========================================
+.. doxygenfunction:: attachInterrupt
+.. doxygenenum:: ExtIntTriggerMode
-Description
------------
-
-Specifies a function to call when an external interrupt occurs.
-Replaces any previous function that was attached to the interrupt.
-Most Arduino boards have two external interrupts: numbers 0 (on
-digital pin 2) and 1 (on digital pin 3). The Arduino Mega has an
-additional four: numbers 2 (pin 21), 3 (pin 20), 4 (pin 19), and 5
-(pin 18).
-
+.. doxygentypedef:: voidFuncPtr
-
-Parameters
+Discussion
----------
-**interrupt**: the number of the interrupt (*int*)
-
-
-
-**function**: the function to call when the interrupt occurs; this
-function must take no parameters and return nothing. This function
-is sometimes referred to as an *interrupt service routine.*
-
-
-
-**mode** defines when the interrupt should be triggered. Four
-contstants are predefined as valid values:
-
-
-- **LOW** to trigger the interrupt whenever the pin is low,
-- **CHANGE** to trigger the interrupt whenever the pin changes
- value
-- **RISING** to trigger when the pin goes from low to high,
-- **FALLING** for when the pin goes from high to low.
-
-
-
-Returns
--------
-
-none
-
-
+Specifies a function to call when an external interrupt occurs.
+Replaces any previous function that was attached to the interrupt.
+For more information on external interrupts on the Maple
Note
----
-*Inside the attached function, delay() won't work and the value returned by millis() will not increment. Serial data received while in the function may be lost. You should declare as volatile any variables that you modify within the attached function.*
-
+Inside the attached function, delay() won't work, and the value
+returned by millis() will not increment. Serial data received while in
+the function may be lost. You should declare as volatile any variables
+that you modify within the attached function.
Using Interrupts
@@ -84,18 +55,18 @@ Example
::
- int pin = 13;
+ int maple_led_pin = 13;
volatile int state = LOW;
void setup()
{
- pinMode(pin, OUTPUT);
+ pinMode(maple_led_pin, OUTPUT);
attachInterrupt(0, blink, CHANGE);
}
void loop()
{
- digitalWrite(pin, state);
+ digitalWrite(maple_led_pin, state);
}
void blink()
@@ -104,6 +75,14 @@ Example
}
+Arduino Compatibility Note
+--------------------------
+
+Most Arduino boards have two external interrupts: numbers 0 (on
+digital pin 2) and 1 (on digital pin 3). The Arduino Mega has an
+additional four: numbers 2 (pin 21), 3 (pin 20), 4 (pin 19), and 5
+(pin 18).
+
See also
--------