What is PIR sensor with Arduino Leave a comment

A Passive Infrared (PIR) sensor is a type of electronic sensor that is use to detect motion in its surrounding environment. It operates based on the principles of infrared radiation detection. PIR sensors are commonly use in various applications, including security systems, automatic lighting, and energy-saving devices.

Here’s How a PIR sensor works

Infrared Detection: PIR sensors can detect infrared radiation emitted or reflected by objects in their field of view. All objects with a temperature above absolute zero (-273.15°C or -459.67°F) emit infrared radiation, so even inanimate objects can trigger a PIR sensor if they have a temperature different from their surroundings.

Pyroelectric Sensor: The core component of a PIR sensor is a pyroelectric sensor or pyroelectric detector. This sensor is made of a crystalline material that generates a voltage when expos to changes in temperature. When an object moves in front of the sensor, it causes a change in the amount of infrared radiation received by the sensor, which, in turn, generates a voltage signal.

Dual Sensors: Most PIR sensors have two pyroelectric sensors arranged in a specific pattern. These sensors are orient so that they can detect motion across their field of view. By comparing the signals from both sensors, the PIR sensor can distinguish between real motion and false alarms caused by changes in temperature, such as those due to changes in ambient temperature.

Signal Processing: The voltage signals from the pyroelectric sensors are then processe by an onboard circuitry, which may include an amplifier, a filter, and a comparator. The circuitry analyzes the voltage changes and, if they exceed a certain threshold and meet the criteria for motion detection, triggers an output signal.

Output: PIR sensors typically have a digital output, often in the form of a voltage pulse or a logical high/low signal. This output can be use to activate other devices, such as alarms, lights, or cameras when motion is detect.

Arduino code

Sensitivity and Range: PIR sensors can be adjuste for sensitivity and range by changing their settings or adding a Fresnel lens in front of them. The sensitivity determines how small of a motion can trigger the sensor, while the range sets the distance over which the sensor can detect motion.


* Company Name:LK Tronics
* Author: Research & Development Department
* Date: 2020/ 03/20
* https://lk-tronics.com/
* All rights reserved. No part of this code may be reproduced, distributed,
* or transmitted in any form or by any means, including photocopying, recording,
* or other electronic or mechanical methods, without the prior written permission
* of LK Tronics, except in the case of brief quotations embodied in
* critical reviews and certain other noncommercial uses permitted by copyright law.


void setup() {
  pinMode(2, INPUT);    // initialize sensor as an input
  Serial.begin(9600);        // initialize serial

void loop(){
  int val = digitalRead(2);   // read sensor value
  if (val == 1) {           // check if the sensor is HIGH
    Serial.println("Motion detected!"); //Print "Motion detected!"
    delay(300);                // delay 100 milliseconds   
  else {
        Serial.println("Motion stopped!"); //Print "Motion stopped!"



Leave a Reply