Arduino Programming Language: DetachInterrupt

Name

detachInterrupt()

Description

DetachInterrupt()method dsables a specific interrupt.

Syntax

detachInterrupt(interrupt)
detachInterrupt(pin) (Arduino Due only)

Parameters

  • interrupt: the number of the external interrupt to disable
  • pin: the pin number of the interrupt to disable

Returns

none 

Usage

Application

Examples

int pinLed = 4;
volatile int state = LOW;
int count=0;
void setup()
{
pinMode(pinLed, OUTPUT);
attachInterrupt(1, blink, RISING);
Serial.begin(9600);
}

void loop()
{
count=count+1;

if(count>2000)
{
detachInterrupt(1);
Serial.print("Interrupt disabled");
}
else{
digitalWrite(pinLEd, state);
}
}
void blink()
{
state = !state;
}

Related Functions


Based on the reference originally written by Arduino Community,  wiring.org.co and  arduino.cc