Detecting motion using PIR Motion Sensor

🕒 2 min read

Have you ever wanted to know how a device that warns you when someone broke into your house while you are asleep in the middle of the night? Or how the lights are turned on automatically when you enter a dark room? Well, all this device or system stated above actually uses a PIR Motion Sensor.

What is a PIR Motion Sensor?


Starting out, PIR Sensor actually stands for “Passive infra-red Sensor. The word “passive” means that the sensor does not generate/ emit any energy for detection. Since it is a “PIR” sensor, this means that this sensor will actually detect infra-red radiation radiated from objects without emitting anything. But since this is a motion sensor, this sensor will instead detect any movement or motion of objects that emit infra-red radiation.

The orange potentiometer you see at the side of the PIR motion sensor is actually for adjusting the sensitivity of the sensor and the duration it will remain “alert” (or the “cooldown time” for a trigger)


For this tutorial…

In this project, I use the PIR Motion Sensor to detect any movement infront of my door, and the buzzer will “buzz” when someone walks into the room. This is particularly simple and useful to notify me if anyone has entered my room. Here is a closer look of the layout of the tutorial.


In this demo, I’ll be using my hand as a substitute for a person entering for demo purposes.



[Coming soon]



const int ledPin=13;//The led to indicate the motion

void setup(){
   pinMode(2, INPUT);//Use pin 2 to receive the signal outputted by the            module 
   pinMode(ledPin, OUTPUT);

void loop() {
   int sensorValue = digitalRead(2);
      digitalWrite(ledPin,HIGH);   //For debugging purposes
      digitalWrite(6,HIGH);   //To make the beep sound
      Serial.println(sensorValue, DEC);//Print the state of the signal through the serial monitor.


Share your love

Leave a Reply

Your email address will not be published. Required fields are marked *