Mega 2560 External interrup

Hii ,

I have mega 2560 and I use external interrup 0 (pin 2) and it is triggered falling edge. But it works very very slow . For example , pin 2 is high when ever it fall low , interrup work after 5 secods pass... Code is at below . Thank any help....

int pin = 13;
volatile int state = LOW;

void setup()
{
  Serial.begin(115200);
  pinMode(2, INPUT);
  pinMode(pin, OUTPUT);
  attachInterrupt(0, fiber, FALLING);
}

void loop()
{
  
}

void fiber()
{
  state = !state;
  digitalWrite(pin, state);
  
}

Do you have a drawing or schematic of your setup?

I know the Reference page says that INT0 is on pin2 on a Mega but from looking at the pin mapping I think pin2 is INT4. And INT0 is on pin 21. Look at this page.

I have never tried interrupts on my Mega (only on my Uno) so this is very speculative.

...R

I have no so complicate schematic , I only use a wire from 5v to pin 2 .... Thanks any help

Dear friends
I solved problem , if you can look schematic of mega 2560 , you can see INT0 is pin 21 .... Thank you all of you

turev:
Dear friends
I solved problem , if you can look schematic of mega 2560 , you can see INT0 is pin 21 .... Thank you all of you

http://arduino.cc/en/uploads/Main/arduino-mega2560_R3-sch.pdf

As in Reply #2, above.

And please don't double post.

...R

Robin2 sorry , I did not see your comment , you already said solution... Thank you