Earn Maker Points on Every Order! Learn More!

PIR Sensor with Arduino Uno

Back to Blog
PIR Sensor with Arduino Uno - PIR Sensor with Arduino Uno - PIR Sensor with Arduino Uno - PIR Sensor with Arduino Uno

PIR Sensor with Arduino Uno

PIR Sensor is a passive infrared sensor which senses IR (Infrared) emitted by humans (all objects emit a certain amount of IR). A hotter object emits more IR than a colder one.

The PIR Sensor is also called as Pyroelectric IR Sensor, Passive Infrared Sensor or IR Motion Sensor. The applications of PIR are Burglar Alarm, Motion detected Floor Lamps, Automatic Door Open System and more.

The PIR Works on a change in the difference of IR Levels on the two Layers of its Lens. Means, the sensor (Inside the round metal with a rectangular crystal in the center) is split into two half on the Lens Area, where signals are opposite to each other.

In default condition on the two layers, the difference in two signal will cancel each other and don’t trigger any output. When a human crosses, the variation of IR levels in PIR output’s a trigger. This trigger signal is then processed and output the signal by an IC on the PIR Module.

PIR-Sensor-WorkingNote: The sensitivity and delay time of the sensor can be adjusted on the module by the two potentiometers on it.

Sensitivity: The sensitivity determines the Range of the Sensor. It ranges from 3 to 5 meters.

Delay Time: It determines how long the output of the PIR Sensor remains HIGH.

In this project, we will see how to use PIR Sensor with Arduino Uno and will light up an LED (You can use buzzer alternatively).

Circuit Diagram:

PIR Sensor with Arduino_bb

Arduino Code:

/* PIR Sensor with Arduino */

int pirSensor = 8;
int relayInput = 13;

void setup() {
pinMode(pirSensor, INPUT);
pinMode(ledpin, OUTPUT);
Serial.begin(9600); 
}

void loop() {
int sensorValue = digitalRead(pirSensor);

if (sensorValue == 1) {
digitalWrite(ledpin, HIGH); 
Serial.println("Detected");
}
else{
digitalWrite(ledpin, LOW);
Serial.println("Not detected");
}
}

In the above code, we are assigning the PIR Sensor as INPUT at Pin 8 and LED as OUTPUT at Pin 13.

Next, We store the PIR Sensor Value to a variable called ‘sensorValue’. By using an if else loop, we are Turning ON and OFF the LED as well as printing the result in the Serial Monitor. The Potentiometer on the PIR is used to adjust the sensing time of the PIR Sensor. So the output time will vary according to the Sensor Delay.

Upload the code and test it. Additionally, add a buzzer to this and try to play with it.

Share this post

Leave a Reply

Back to Blog