detachInterrupt(0) in arduino not working ? after giving continuous ground to INT0 wakeupnow function should execute once not again and again #include &lt;avr/sleep.h&gt;  

int wakePin = 2;                 // pin used for waking up  
int led=13;
int flag=0;

void wakeUpNow() 
{  
  // execute code here after wake-up before returning to the loop() function  
  // timers and code using timers (serial.print and more...) will not work here.  
  // we don't really need to execute any special functions here, since we  
  // just want the thing to wake up  
  int count=10;
  while(count!=0)
  {
    delay(1000);
    count--;
    Serial.println(count);  
    delay(1000);   
  }
}  

void setup() 
{  
  Serial.begin(9600);
  pinMode(wakePin, INPUT_PULLUP);  // wakePin is pin no. 2
  pinMode(led, OUTPUT);          //   led is pin no. 13
  attachInterrupt(0, wakeUpNow, LOW); // use interrupt 0 (pin 2) and run function wakeUpNow when pin 2 gets LOW
}  

void sleepNow() 
{  
    set_sleep_mode(SLEEP_MODE_PWR_DOWN);   // sleep mode is set here  
    sleep_enable();                        // enables the sleep bit in the mcucr register  
                      delay(500);  
                      Serial.println("Rajat");  
                      delay(500);
    attachInterrupt(0,wakeUpNow, LOW); // use interrupt 0 (pin 2) and run function  
                      delay(500);  
                      Serial.println("Rajat");  
                      delay(500);
    sleep_mode();     // here the device is actually put to sleep...!!
      // THE PROGRAM CONTINUES FROM HERE AFTER WAKING UP    
                      delay(500);  
                      Serial.println("Rajat2");  
                      delay(500);
    detachInterrupt(0);      // disables interrupt 0 on pin 2 so the wakeUpNow code will not be executed during normal running time. 
    sleep_disable();         // first thing after waking from sleep: disable sleep...  
                      delay(500);  
                      Serial.println("Rajat3");  
                      delay(500);
       detachInterrupt(0);      // disables interrupt 0 on pin 2 so the wakeUpNow code will not be executed during normal running time. 

}  

void loop() 
{ 
      digitalWrite(led, HIGH);   
      delay(1000);  
      digitalWrite(led, LOW);
      delay(1000);  
    /* delay(500);  
      Serial.println("jam");  
      delay(500);  */
      if (flag==0)
      {
      sleepNow();     // sleep function called here
      flag=1;
      }
}  


After Last Rajat I give ground to INT0.

Output in serial monitor :

Rajat
Rajat
9
8
7
6
5
4
3
2
1
0
9
8
7
6
5
4
3
2
1
0
9
8
7
6
5
4
3
2
1
0
9
8
7
6
5
4
3
2
1
0
9
8
7
6
5
4
3
2
1
0
9
8
7
6
5
4
3
2
1
0
9
8
7
6
5
4
3
2
1
0
9
8
7
6
5
4
3
2
&amp; so on..!
You're detaching in completely the wrong place. After sleep_mode() returns from sleep and before the interrupt is detached you have an entire second of time where your interrupt can still fire. And it will fire, since a LOW interrupt will keep firing while the input is LOW.

sleep_mode();     // here the device is actually put to sleep...!!
  // THE PROGRAM CONTINUES FROM HERE AFTER WAKING UP    
                  delay(500);  
                  Serial.println("Rajat2");  
                  delay(500);
detachInterrupt(0);   


Instead you should detach the interrupt within the interrupt routine itself:

void wakeUpNow() 
{  
  // execute code here after wake-up before returning to the loop() function  
  // timers and code using timers (serial.print and more...) will not work here.  
  // we don't really need to execute any special functions here, since we  
  // just want the thing to wake up  

    detachInterrupt(0);   

  int count=10;
  while(count!=0)
  {
    delay(1000);
    count--;
    Serial.println(count);  
    delay(1000);   
  }
}  


Also, all those delays and Serial prints in an interrupt are seriously problematic. An interrupt should never delay() and should never Serial.println().