aboutsummaryrefslogtreecommitdiffstats
path: root/source/arduino/attachinterrupt.rst
diff options
context:
space:
mode:
Diffstat (limited to 'source/arduino/attachinterrupt.rst')
-rw-r--r--source/arduino/attachinterrupt.rst69
1 files changed, 24 insertions, 45 deletions
diff --git a/source/arduino/attachinterrupt.rst b/source/arduino/attachinterrupt.rst
index 27a1d77..189141b 100644
--- a/source/arduino/attachinterrupt.rst
+++ b/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
--------