Introduction: Wiring the PIR

The PIR is an easy to use passive detector that uses Infrared to detect IR light from objects.There are only three connections to the Arduino.

These sensors can be used for motion detection, burglar alarms, night lights, or how about an automatic doorbell.

You can turn on a relay, a light, a buzzer, your TV or just about anything with these!

Step 1: Wiring and Code

Note: Check your pins on the PIR
Shown above

RED is Vcc

Black is Gnd

Yellow is Input

Here is the code:

Begin ============================================

/* This sketch uses a PIR sensor(Passive Infrared Detector) The output pin on the PIR is connected to Arduino Pin 2. When IR Motion is detected Arduino pin 13 will light. */

const int ledPin = 13; //This is the onboard LED

const int inputPin = 2; //input pin for the PIR

void setup()

{

pinMode(ledPin, OUTPUT); //LED on pin 13 will be an output

pinMode(inputPin, INPUT); //input from PIR

}

void loop()

{

int val = digitalRead(inputPin); //get the input value from PIR and place it into val

if (val==HIGH)

{

digitalWrite(ledPin, HIGH); //turn on LED if motion detected

delay(10); //wait

digitalWrite(ledPin, LOW); //then turn off LED

}

}

//=======================================================

So depending on your use you could ring a doorbell when someone approaches (a visitor, the mailman, etc.) Perhaps as a night light or a burglar alarm for doors or windows. As this is basically a switch it can be used for tons of different things. Have fun and see what you can come up with! I would be interested to hear what you have made!