PIR sensor acting odd...

Hey everyone, I am trying to wire up two different PIR sensors to a mega (and have been trying to test them independently), however they have been acting a little odd with the test program. I do not have LEDs (but this doesn't seem to matter) and have just been trying to test them through the serial monitor, but they rapidly alternate output between 'motion detected' and 'motion ended' so I'm not sure what I may be missing here. Thanks!

/*
 * PIR sensor tester
 */
 
int ledPin = 13;                // choose the pin for the LED
int inputPin = 2;               // choose the input pin (for PIR sensor)
int pirState = LOW;             // we start, assuming no motion detected
int val = 0;                    // variable for reading the pin status
 
void setup() {
  pinMode(ledPin, OUTPUT);      // declare LED as output
  pinMode(inputPin, INPUT);     // declare sensor as input
 
  Serial.begin(9600);
}
 
void loop(){
  val = digitalRead(inputPin);  // read input value
  if (val == HIGH) {            // check if the input is HIGH
    digitalWrite(ledPin, HIGH);  // turn LED ON
    if (pirState == LOW) {
      // we have just turned on
      Serial.println("Motion detected!");
      // We only want to print on the output change, not state
      pirState = HIGH;
    }
  } else {
    digitalWrite(ledPin, LOW); // turn LED OFF
    if (pirState == HIGH){
      // we have just turned of
      Serial.println("Motion ended!");
      // We only want to print on the output change, not state
      pirState = LOW;
    }
  }
}

I think I spotted the problem- seems that these need pull up resistors (internal or external), but I'm not sure how to incorporate that in turning on the internal pull up for that pin.

Nevermind, wasn't it

I got it! Seems that the ground and vcc were switched (on the actual circuit, not my mistake this time ;P), i just so happened to come across a couple people elsewhere on the internet who were answering someone else's question troubleshooting, figured why not try it, and sure enough now that was it (just had to adjust the sensitivity potentiometer on the sensor accordingly but now they both work like a charm).