• 1 x Arduino Uno ( You can use other boards also )
  • 10 x Jumper Wires M-F
  • 1 x Breadboard
  • 1  x  RGB LED
  • 1 x PIR sensor

PIR sensor

Image result for pir sensor

Description

A  PIR (passive infrared sensor) sensor is an electronic  sensor  that measures Infrared(IR) light radiating from objects in its field of view. They are most often used in PIR-based motion detectors.

  1. An individual PIR sensor detects changes in the amount of infrared radiation falling upon it, which varies depending on the temperature and surface characteristics of the objects in front of the sensor.
  2. PIR  have three pins,  one is vcc and third one is GND. The middle pin is  the output pin.

Here, it is used  as a digital input and the LED is used as digital input.

QUICK POINTS

•This is a basic program on PIR sensor which is sense the motion of human,animals and any object.
•You can use inbuilt LED which on Digital Pin no 13.

Min Required-20min

LINES OF CODE

int LED = 13;
int inputPin = 2;
int PIR_STATE = LOW;
int VALUE = 0;

void setup() {
pinMode(LED, OUTPUT);
Serial.begin(9600);
}

void loop(){
VALUE = digitalRead(inputPin);
if (VALUE == HIGH) {
digitalWrite(LED, HIGH);
if (PIR_STATE == LOW) {
// ————–we have just turned on
Serial.println(“Motion has been detected!”);
PIR_STATE = HIGH;
}
}

else

{
digitalWrite(LED, LOW);
if (PIR_STATE == HIGH){
// ———we have just turned of
Serial.println(“Motion has been stopped!”);
PIR_STATE = LOW;
}
}
}

Procedure

1 )Take a Breadboard.
2)Take a LED it will have one big leg (+) which is a positive and small leg which is Negative.
3)Press the two legs and remember which one is a big one ( You can even bend big leg so it’s easy to identify for further reference. otherwise you can use inbuilt LED of arduino which is a pin no. 13.)
4)Now take 2 M-M jumper wires and take PIR sensor.

5)Now, connect GND pin of PIR sensor to the GND of arduino.
6)connect  vcc pin to the +5v of arduino board. and output pin of a sensor to the digital pin no. 2
if you are using LED externally than connect LED to the pin no. 13 of arduino board.

7)Check once again with a circuit to avoid any short circuit.
8)Connect Arduino to your Laptop/PC by USB Cable.( we use A to B USB cable for Arduino which is also used in printers )
9)Open Arduino IDE ( You can download it from here or you can use online platform Arduino Web editor )
10)Go to File > New >write a code which is given above.
11)Check program and then upload it.
12)You can change any other device as output. here LED is used.

Image result for pir sensor interfacing with arduino