Using Interrupts

Does anyone knows how to use Interrupt only once.

for example :
int pin = 13;
volatile int state = LOW;

void setup()
{
pinMode(pin, OUTPUT);
attachInterrupt(0, blink, CHANGE);
}

void loop()
{
digitalWrite(pin, state);
}

void blink()
{
state = !state;
}

In this code that I want that Interrupt should e called only once, and not after that.

void blink()
{
  state = !state;
  detachInterrupt (0);
}

Well, an interrupt is exactly that, when an event happens the processor goes off to deal with it and then returns.

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.

So, is it not easier to simply do something along the lines of..

//loop
{
if (Triggered==false)
{
//ReadPin
//if true
{ YourCode; Triggered=True}
}

meaning it will only execute once saving memory an a waste of time interrupt, interrupts are great for checking things externally but if you're only going to need it once, why bother?
}

yeah or that :smiley: