Arduino with PIR Sensor Project with LED and Buzzer

Arduino with PIR Sensor Project with LED and Buzzer

This project shows you how to automatically turn ON and OFF a LED and Buzzer using an Arduino with PIR Sensor.

The PIR Sensor detects motion by measuring changes in infrared (heat) levels emitted by objects in the surrounding area. When motion is detected, an LED illuminates the lens dome as a visual signal. In addition, the module sends a high signal on its output pin.

Components Required  for the Arduino with PIR Sensor Project

Arduino Uno× 1Amazon
PIR Sensor× 1Amazon
Buzzer × 1 Amazon
LED and Resistor Kit× 1Amazon
5V Relay Module× 1Amazon
Breadboard× 1Amazon
Jumper wires× 2Amazon
USB cable type A/B× 1Amazon

Disclosure: These are affiliate links. As an Amazon Associate, I earn from qualifying purchases.


Arduino IDE

What is PIR Sensor or PIR Motion Sensor?

PIR Sensor orPIR Motion Sensor is an electronic sensor that detects changes in infrared light over a certain distance and outputs an electrical signal in response to a detected IR signal. They are small, cheap, low-power, simple to use, and do not wear out. As a result, they are frequently found in appliances and gadgets used in homes and businesses. They are also known as PIR, “Passive Infrared,” “Pyroelectric,” or “IR motion” sensors.

The PIR Sensor is basically composed of a pyroelectric sensor (which can be seen below as a round metal with a rectangular crystal in the centre), that can detect levels of infrared radiation. Everything emits some radiation, and the hotter things emit the greater radiation. In fact, the sensor is split into two halves in a motion detector. The reason is that we try not to detect an average level of IR for motion (change). The two halves are wired to cancel one another. That’s because we’re trying not to detect average IR motion (change) levels. The two halves are wired up to cancel one another. When a half of the radiation is more or less IR, the output swings high or low.

The sensor has a controllable sensitivity that allows motion detection range of 3 meters to 7 metres, as well as includes time delay changes and selection of triggers for fine tuning within your application.

Key Features:

  • Typically detects person up to 30 feet away, or up to 15 feet away in low sensitivity mode. 
  • Field of view is approximately 90 degrees.
  • Easy integration in permanent applications is made possible by mounting holes for 2-56 sized screws.
  • The dome is illuminated by LEDs as a visual signal of sensor activation.
  • Communication with any microcontroller is simple.
  • The 3-pin SIP package is ideal for projects that require a breadboard.
  • Its small size makes it simple to hide.


  • Adjusting the distance potentiometer clockwise increases the sensing distance (about 7 meters), while counterclockwise decreases the sensing distance (about 3 meters).
  • Adjust the delay potentiometer clockwise to lengthen the delay (300S), or clockwise to shorten the induction delay (5S).

Typical Applications:

  • Lighting: lamp, automatic switch, street lighting, motion-activated nightlight
  • Anti-crime devices: security camera, crime-prevention
    sensor,  security light, Night security alarm
  • Home appliance: air conditioner, air purifier, fan heater
  • Audio and Visual devices: TV, PC, display
  • Commercial equipments: vending machine, copy machine

PIR Sensor Specifications

Voltage5V-12V DC
Power Consumption65mA
PIR Sensor rangeWithin 7 meters, less than 120°
Angle Sensor<110° Cone Angle
Delay Time5 – 300S (Adjustable) Range (approximately 0.3Sec – 5Min)
Lock Time0.2sec
Block Time2.5S (Default) Can be made a range (0.xx to tens of seconds
Temperature-15°C ~ +70°C
Trigger MethodsL – Disable Repeat Trigger, H – Enable Repeat Trigger
Dimension32 × 24mm
Cost Check Price

For more information, you can check out the PIR Sensor Datasheet below:

Circuit Diagram of PIR Sensor with Arduino, LED and Buzzer

Circuit Diagram of PIR Sensor with Arduino, LED and Buzzer
Circuit Diagram of PIR Sensor with Arduino, LED and Buzzer

PIR Sensor‘s  Out Pin connected to digital pin 2. LED connected from digital pin 4 to ground through a 220ohm resistor. And Buzzer connected to digital PWM(~) pin 5.

PIR sensor Arduino Code with LED and Buzzer

By clicking the button in the top right corner of the code field, you can copy the code. Copy and paste it into Arduino IDE. 

/*** ***/
/*** Arduino with PIR Sensor LED and Buzzer ***/
int PIRSensor = 2; //Define PIR Sensor pin
int Buzzer = 5; //PWM (~) pin
int LED = 4; //Define LED pin
int SensorValue = 0; // Initializing the value as zero at the beginning
void setup() {
pinMode(Buzzer, OUTPUT);
pinMode(LED, OUTPUT);
pinMode(PIRSensor, INPUT);

void loop() {
SensorValue = digitalRead(PIRSensor); // The value read from PIR Sensor pin 2 will be assigned to 'SensorValue'
if(SensorValue == HIGH){
  digitalWrite(LED, HIGH); // Turn LED ON
  tone(Buzzer, 5000); //the buzzer sound frequency at 5000 Hz. The frequency range is from 31 Hz to 65535 Hz.
  Serial.println("Motion Detected"); // Print this text in Serial Monitor
  digitalWrite(LED, LOW);
  Serial.println("Motion not Detected");


 You should see your LED and Buzzer turn ON when an object or motion comes in the range of the PIR Sensor. If you cannot see the desired output, ensure the circuit has been properly assembled, and verified, and uploaded the code to your board.

  1. Make automated security light with PIR Sensor.
  2. You can make an Arduino night security alarm with PIR Sensor.
  3. Also, You can make motion-activated nightlights with Arduino and PIR Sensor.

Leave a Reply