Problem reading PIR sensor

Hello people

I have trouble reading og a PIR sensor and i can't see what im doing wrong. Im following the tutorial on http://bildr.org/2011/06/pir_arduino/

The problem is that it keep printing motion detected no matter what i do. :frowning:

I used the code used in the tutorial:

int pirPin = 2; //digital 2

void setup(){
 Serial.begin(9600);
 pinMode(pirPin, INPUT);
}

void loop(){
  int pirVal = digitalRead(pirPin);

  if(pirVal == LOW){ //was motion detected
    Serial.println("Motion Detected");
    delay(2000);
  }

}

I've added a picture as the hook up aswell:

This is the sensor you use : PIR Motion Sensor (JST) - SEN-13285 - SparkFun Electronics ?
I can't see the problem, the wiring and sketch seems okay.

Do you have a multimeter, to check the output of the PIR sensor ?

I don't have that no.. :confused:

But i do have three of the sensors laying here and they are all acting the same way.

edit: and yes that is the sensors i use.

Well, I have a PIR sensor here, that keeps 'seeing' motion if it is above 25 degrees.
Or it could take 10 minutes after startup.
Did you wait half an hour ?

no i hav'nt tried that. Would it make any difference? This is what is says from the site where i got it from:

"This is a simple to use motion sensor. Power it up and wait 1-2 seconds for the sensor to get a snapshot of the still room. If anything moves after that period, the 'alarm' pin will go low.

Red wire is power (5 to 12V). Brown wire is GND. Black wire is open collector Alarm.

This unit works great from 5 to 12V (datasheet shows 12V). You can also install a jumper wire past the 5V regulator on board to make this unit work at 3.3V. Sensor uses 1.6mA@3.3V.

The alarm pin is an open collector meaning you will need a pull up resistor on the alarm pin. The open drain setup allows multiple motion sensors to be connected on a single input pin. If any of the motion sensors go off, the input pin will be pulled low.

The connector is slightly odd but has a 0.1" pitch female connector making it compatible with jumper wires and 0.1" male headers."

edit: waiting did'nt give anything.

I haven't got any clue.

The pull-up resistor could make bad contact.
If you disconnect the sensor (so the pull-up resistor will keep the signal high) does that stop the messages "motion detected" ? If that doesn't stop it check the resistor.

You need a multimeter to measure the voltages of the sensor. The cheap digital ones are only 4 or 5 euros/dollars on Ebay, and that includes shipping.

If want to test the sensor to rule out if sensor is the issue, you can do it with test circuit in step 4 without multimeter. All the best!

check the wiring on your sensor. much to my dismay, i received a few that had wiring as follows:

Brown - Ground
Red - Signal
Black - 5v

it was strange connecting 5v to the black wire but it worked.