PIR Motion Sensor Arduino Interfacing Tutorial

PIR(Passive Infrared Sensor) sensor is an electronic sensor that measures the infrared light level reflected from the object. This concept is used in PIR-based motion detectors.

If you want something to happen when you walk into the room, like turn on the lights to detect unwanted person’s trespassing or any devices you want to turn ON and OFF. This motion can be detected by checking for a high signal on a single I/O pin. We simply need the motion sensor for such kind of applications. There are different motion sensor based security system in the market using the same concept.

Interfacing PIR motion sensor with arduino is very easy. When it sense any movement, it sends a digital output and arduino take decisions accordingly like turn ON/OFF the alarm or lights. You should know how to work on digital input in arduino.

To work on this digital input you should know arduino digital input programming.

Hardware Required

  • Arduino Uno
  • PIR Motion Sensor
  • LED
  • Resistor 220 ohm

PIR Pinout and Rating

Pin Name Function
GND Connects to Ground or Vss
+ Vcc Connects to Vdd (3.3V to 5V) @ ~100uA
OUT Output Connects to an I/O pin set to INPUT mode

PIR Jumper Setting

Position Mode Description
H Retrigger Output remains HIGH when the sensor is retriggered repeatedly. The output is LOW when idle (not triggered).
L Normal Output goes HIGH then LOW when triggered. Continuous motion results in repeated HIGH/LOW pulses. The output is LOW when idle.

PIR Calibration

PIR sensor needs some “warm-up” time to function correctly. Because there is some settling time involved in learning its environmental conditions. This time is approx 10-60 seconds. During this time there should be a slow motion in sensors field of view.

PIR Sensitivity

PIR sensor has a range approx 20feet and depends on environmental conditions. It is designed to adjust in slowly changing conditions this generally happens when day progresses. It responds by giving a high signal on the sudden change in its environment.

PIR Motion Sensor Wiring

PIR Motion Sensor Connection with Arduino

Arduino Motion Sensor Code

When a movement is detected by the motion sensor. It gives a high signal to the arduino and arduino turns Led ON. Here in place of Led, we can use alarm or relay for controlling the lights. For this programming, learn arduino switch interfacing.

//PIR Motion Sensor Interfacing
 const int PIRinput = 8;   //PIR connected here
 const int led =  13;      //Led connected here
 int motion = 0;
 void setup() {
  pinMode(led,HIGH);       //led as output
  pinMode(PIRinput,LOW);   //PIR as input

 void loop() {
  //reading the PIR status and stores to variable motion
  motion = digitalRead(PIRinput);   
  if (motion == HIGH) {
   digitalWrite(led, HIGH);
  else {
   digitalWrite(led, LOW);