Experiment 7 - PIR Sensor
Experiment 7 - PIR Sensor
Components required:
Software Hardware
Arduino UNO Board
Arduino UNO Cable
Tinkercad PIR Sensor
Arduino IDE (To be installed in Laptop) LED (Red-1)
Buzzer - 1
Resistors – 1 (220Ω each)
Jumper wires
Description:
PIR stands for Passive Infrared Sensor.
It is called passive sensor because it does not emit the IR rays. It only receives the IR rays.
It is non wearable device for that reason they are commonly found in appliances and gadgets
used in homes or businesses.
It is having 3 pin structure where , Pin 1 is Vcc (+5v), Pin 2 is Output and Pin 3 is ground All
pins must be connected with arduino pins.
PIR sensor can detect animal/human movement in a requirement range. For Indoor passive
infrared Detection distances range from 25 cm to 20 m For Outdoor passive infrared, the detection
distance ranges from 10 meters to 150 meters.
It detects infrared radiation from the environment. Once there is infrared radiation from the human
body particle with temperature, focusing on the optical system causes the device to generate a sudden
electrical signal.
Pre lab:
Once the sensor detects any motion, Arduino will send a message via the serial port to say
that a motion is detected. The PIR sense motion will delay for certain time to check if there
is a new motion. If there is no motion detected, Arduino will send a new message saying
that the motion has ended.
Connect the Gnd pin of sensor to the ground of Arduino. Vcc pin of the sensor to 5V of
Arduino. And signal / output pin to digital pin 5 of Arduino board. Led connections -
Positive terminal of the led to digital pin 9 of Arduino.
A passive infrared sensor (PIR 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. PIR sensors are commonly used in security alarms and automatic lighting
applications.
In lab:
Program:
int sensorval=0;
void setup()
{
Serial.begin(9600);
pinMode(3, INPUT);
pinMode(7, OUTPUT);
pinMode(8, OUTPUT);
}
void loop()
{
sensorval=digitalRead(3);
if (sensorval == HIGH)
{
tone(7,800);
digitalWrite(8, HIGH);
Serial.println("Motion of object Detected");
}
else
{
noTone(7);
digitalWrite(8, LOW);
Serial.println("No Motion of object");
}
delay(1000);
}
Connection Diagram:
PROCEDURE:
1. Give the connections to the Arduino board as shown in the connection diagram.
2. Open Arduino IDE in the computer
3. Create new file File_--→ New
4. Type your program and Save it in appropriate location in your computer.
5. Compile your program by clicking Verify option in the menu.
6. Once the program compiled successfully, connect the Arduino board to the computer using
USB cable.
7. After connecting, go to Tools ----→Board ---→ Select Arduino/Genuino Uno option
8. After selecting board, go to Tools ----→Port ---→ Select Arduino Uno COM port 3
(name may appear differently for other computers).
**Note that this port option will be displayed only when board is connected to computer
9. Now upload the program to the Arduino board by clicking Upload option.
10. Once the program uploaded successfully, open serial monitor window in Arduino IDE to
see the value of PIR sensor. When you give motion Infront of sensor, observe the value
changes in serial monitor.
Schematic Diagram:
Result:
Inferences/Analysis:
POST-LAB
Code:
int SensorValue;
void setup()
{
pinMode(13, INPUT);
pinMode(3, OUTPUT);
Serial.begin(9600);
}
void loop()
{
SensorValue = digitalRead(13);
Serial.println(SensorValue);
if (SensorValue ==HIGH)
{
digitalWrite(3,HIGH);
}
else
{
digitalWrite(3,LOW);
}
}
Viva Questions:
Connect the Gnd pin of sensor to the ground of Arduino. Vcc pin of the sensor to 5V of
Arduino. And signal / output pin to digital pin 5 of Arduino board.
A PIR (Passive Infrared) sensor is typically a digital sensor. It provides a digital output
signal, typically in the form of a logic high or low, indicating the presence or absence of
motion. The sensor's output is not continuous or analog, but rather discrete and digital in
nature.
RESULT: