void attachInterrupt( uint32_t pin, callback_ptr callback, uint32_t mode );
void attachInterrupt( uint32_t pin, callback_ptr callback, uint32_t mode );
Sets up Interrupt Service Routine (ISR). When an interrupt arrives, the ISR will be called automatically. This interrupt service cannot preempt execution. When the next interrupt arrives, it will wait for ISR to finish the previous interrupt before its execution starts. There are two external interrupts on LinkIt One development board, interrupt 0 (at pin 2) and interrupt 1 (at pin 3).
|
Parameters |
Description |
|
uint32_t pin |
[IN] Interrupt id, should be 0, and 1; 0 corresponds to pin2 (D2), 1 corresponds to pin3 (D3). |
|
callback_ptr callback |
[IN] Interrupt callback |
|
uint32_t mode |
[IN] Interrupt trigger mode, it should be RISING/FALLING/CHANGE |
int pin = 13; volatile int state = LOW; void setup() { pinMode(pin, OUTPUT); attachInterrupt(0, blink, RISING); } void loop() { digitalWrite(pin, state); } void blink() { state = !state; }
WInterrupts.h