Go Down

Topic: Cheap PIR motion sensor from Ebay wiring question (Read 915 times) previous topic - next topic

Scott Baker

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.

Automative

#1
Aug 30, 2012, 02:24 am Last Edit: Aug 30, 2012, 02:26 am by Automative Reason: 1
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: [Select]

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/

Scott Baker



Go Up
 


Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

Arduino
via Egeo 16
Torino, 10131
Italy