Random behaviour when using interrupt and PIR sensor

Hi, Here I have a sketch which is suppose to generate interrupt when the PIR signal is LOW. The sketch behaves randomly whenever I put my hand in front of the PIR sensor. As soon as I put my hand in front of the PIR sensor the serial monitor stops logging and I have to reset. Can anyone please let me know what I am doing wrong ?

Not sure if it's a power issue but for information, the arduino is powered using the laptop usb power and the PIR sensor had worked perfectly in that setup.

Below is the snippet from the serial monitor –

No Motion Detected
No Motion Detected
No Motion Detected
No Motion Detected
   //stopped ..
 |

The serial monitor stopped I suppose inside the interrupt handler when I put my hand in front of PIR sensor. I am using an arduino UNO, PIR Motion sensor SEN-08630(https://www.sparkfun.com/products/8630). It’s hooked according to this diagram- http://bildr.org/2011/06/pir_arduino/.

The details of my sketch is -

int pirPin = 2 ;
void setup(){
 Serial.begin(9600); 
 // pinMode(pirPin, INPUT);
 attachInterrupt(0, interruptHandler, LOW);
}

void interruptHandler()
{
   noInterrupts();
   Serial.println ("Motion Detected");
   //delay(200) ;
   interrupts();
}

void loop(){
    Serial.println("No Motion Detected"); 
    //  int pirVal = digitalRead(pirPin);  //used for debugging
    //  Serial.print("PIR val :  "); 
    //  Serial.println(pirVal); 
    delay(2000); 
}

That sketch will give random results.

You don't have to use "noInterrupts()" and "interrupts()" in a interrupt service routine, please remove them. You can't use "Serial.println()" in a interrupt service routine. The Serial library uses buffers and interrupt and delays itself, and that might cause a problem if called from an interrupt service routine. You may never use "delay()" in a interrupt service routine.

You can set a variable in the interrupt service routine. Make that variable 'volatile', and check it in the "loop()" function.

volatile boolean motion = false;

void interruptHandler()
{
  motion = true;
}

Thanks. Its running smooth as whistle!