Pages: [1]   Go Down
Author Topic: Cheap PIR motion sensor from Ebay wiring question  (Read 764 times)
0 Members and 1 Guest are viewing this topic.
Canby, OR
Offline Offline
Full Member
***
Karma: 1
Posts: 158
Arduino rocks
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

I bought a cheap PIR motion sensor from Ebay and I'm not sure how I should be wiring this thing up. I'm assuming 5v to +, Ground to -, and a digital input pin to "Out". Anyone have any idea if I should use a pullup/pulldown resistor? There is very little info to go along with the sensor, so I'm in the dark.
Logged

Belgium
Offline Offline
Newbie
*
Karma: 0
Posts: 8
Automotive Automation
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi,

The sensor will make a vieuw of the room in the first seconds it's powered up.
When there is a detection, it will set it's output pin to LOW.

So a pull up resistor is required.

A simple code like this would give you an alarm over serial
Code:
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);
  }

The code is from a bildr.org tutorial on a simular sensor
http://bildr.org/2011/06/pir_arduino/
« Last Edit: August 29, 2012, 07:26:36 pm by Automative » Logged

Canby, OR
Offline Offline
Full Member
***
Karma: 1
Posts: 158
Arduino rocks
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Perfect that was exactly it.
Logged

Belgium
Offline Offline
Newbie
*
Karma: 0
Posts: 8
Automotive Automation
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

You're welcome smiley-wink
Logged

Pages: [1]   Go Up
Jump to: