PIR sensors are also referred to as Passive Infra Red sensors. They can detect motion of a human or animal from 2 meters distance.  PIR's are basically made of a pyroelectric sensor, which can detect levels of infrared radiation.

Everything emits some level of heat, and the hotter something is the more radiation is emitted. The sensor in a PIR is split in two halves. if one half sees more or less radiation then the other half, the output will go high or low. A body paasing the sensor will activate first one and the the other half. The heat source must pass in a horizontal direction so that the elements of the sensor are sequentially exposed to the IR heat source. A lens is usually in front of the sensor to enlarge the detecting area. The PIR sensor cannot work on its own, it needs a supporting circuitry of resistors and capacitors and an IC. The IC most used is the BISS00001. It takes the output of the analog sensor and processes it to an digital output pulse.

pir sensor 1

Most PIR modules have a 3-pin connection at the side or bottom. One pin will be ground, another will be signal and one will be power. Power is usually 5-12 VDC input. Our PIR module has a 3 pin header for connecting to a cable. The red cable is + voltage power, black cable is - ground power and yellow is the signal out.

pir sensor 2

For many basic projects or products that need to detect when a person has has approached the area, PIR sensors are great. They are low power and low cost, pretty rugged, have a wide lens range, and are easy to interface with. Note that PIRs won't tell you how many people are around or how close they are to the sensor, the lens is often fixed to a certain sweep and distance and they are also sometimes set off by housepets. Experimentation is key!

 Connecting PIR sensors to a microcontroller is really simple. The PIR acts as a digital output so all you need to do is listen for the pin to flip high (detected) or low (not detected). Our module has two modes: non-retrigger and retrigger. It has also an adjustable delay and adjustable sensitivity 
Its likely that you'll want retriggering, so be sure to put the jumper in the H position! Power the PIR with the 5V (red wire) and to ground (black wire). Then connect the output (yellow wire) to a digital pin. In this example we'll use PORTB pin 0.

The code is very simple, and is basically just keeps track of whether the input to PORTB.0 is high or low. It also tracks the state of the pin, so that it prints out a message when motion has started and stopped on the LCD display.

// project : atm328 - PIR sensor
// Version : 1.0
// Website : www,avrprojects.net
// Date Created : 23.12.2016
// Target : ATmega328P microcontroller
// Language : C WINAVR
// Hardware requirements: LCD display, ATM328 board , PIR sensor
// Description : detect movement with a PIR sensor

#include <avr/io.h>
#include <stdlib.h>
#include <string.h>
#include <util/delay.h>
#include <util/lcd.h>

struct DATE{
int month;
int day;
int year;

struct DATE today = {22,12,2016};

void ShowCase (void)
LCDgoto(0,0);LCDtxt ("....PIR sensor.....");
LCDtxt("**** ");
LCDtxt(" ****");

int main(void)
DDRB = 0x00; //set port B as input
LCDcmd (0b00101100);
//turn on display
LCDcmd (0b00001100);
//clr display

if (PINB == 0x00000001)
LCDtxt ("Movement !!!");
LCDtxt (" clear ");

If a motion is detected , the LCD displays the message movement, if nothing is detected it displays the message clear.

pir motion sensor 1

pir motion sensor 2