Introduction: 3.5 $ P.I.R. Arduino Intruder Alarm

About: So basically i am a crazy person, who loves to think the most odd way ever possible,who makes what he thinks and also let other also make those . Check out my crazy projects if you like do follow me :D

Passive infrared sensors are great for motion detection projects, i brought it recently for a college project and i was actually being tempted to use it .
Unfortunately all i got from The INTERNET were not that much fun .
I took out some of my favorite old parts and started tinkering with it .

The result was a motion detected Intruder alarm.
I added two led to simulated police siren light and added Siren to it for the real fun.
The sensitivity was made to medium values , and then the fun began .

Note this might look like an egg according to my Girl Friend dont try to boil it and eat it :P

Step 1: Ingredients

So for this project we would need

You will also need a powerbank as a power source

i used the one i made .
you can also make one

Step 2: About the PIR Sensor

PIRs are basically made of a pyroelectric sensor.The one above as the round metal can with a rectangular crystal in the center.It can detect levels of infrared radiation. Everything emits some low level radiation, and the hotter something is, the more radiation is emitted. The sensor in a motion detector is actually split in two halves. The reason for that is that we are looking to detect motion (change) not average IR levels. The two halves are wired up so that they cancel each other out. If one half sees more or less IR radiation than the other, the output will swing high or low.

There are two Trimmer in the PIR sensor this pots adjust the delay time and the sensitivity ,individually i added the note in the 3rd pic for references.

There is also a jumper for selecting the trigger mode ,

There are two trigger modes

H (re trigger ):Output remains high when sensor is triggered repeatedly and low when idle.

L (Normal ): Output goes hig to low when triggered .Continous motion results in repeated high low pulse

Step 3: Connecting the Sensor and the Components

The PIR sensor has three pins

  1. Vcc
  2. Data
  3. Ground

so the connections are simple we connect

Vcc to 5v

Gnd to Gnd

Data to 3

Now for the siren


positive to pin 11

Gnd to Gnd

Lastlat the Led are connected to 7 and 8

Step 4: Coding Time

About the code .

int calibrationTime = 45;        

//the time when the sensor outputs a low impulse
long unsigned int lowIn;         

//the amount of milliseconds the sensor has to be low 
//before we assume all motion has stopped
long unsigned int pause = 5000;  

boolean lockLow = true;
boolean takeLowTime;  

int pirPin = 3;    //the digital pin connected to the PIR sensor's output
int ledPin = 11;
int led1=8;
int led2=7;

void setup(){
  pinMode(pirPin, INPUT);
  pinMode(ledPin, OUTPUT);
  digitalWrite(pirPin, LOW);

  //give the sensor some time to calibrate
  Serial.print("calibrating sensor ");
    for(int i = 0; i < calibrationTime; i++){
    Serial.println(" done");
    Serial.println("SENSOR ACTIVE");
  void alert()

void loop(){

     if(digitalRead(pirPin) == HIGH){
       analogWrite(ledPin, 50);   

       ;//the led visualizes the sensors output pin state
         //makes sure we wait for a transition to LOW before any further output is made:
         lockLow = false;            
         Serial.print("motion detected at ");
         Serial.println(" sec"); 
         takeLowTime = true;

     if(digitalRead(pirPin) == LOW){   
       digitalWrite(ledPin, LOW);  //the led visualizes the sensors output pin state

        lowIn = millis();          //save the time of the transition from high to LOW
        takeLowTime = false;       //make sure this is only done at the start of a LOW phase
       //if the sensor is low for more than the given pause, 
       //we assume that no more motion is going to happen
       if(!lockLow && millis() - lowIn > pause){  
           //makes sure this block of code is only executed again after 
           //a new motion sequence has been detected
           lockLow = true;                        
           Serial.print("motion ended at ");      //output
           Serial.print((millis() - pause)/1000);
           Serial.println(" sec");
Sensors Contest 2016

Participated in the
Sensors Contest 2016