PIR Sensor with Arduino

Last Updated on March 16, 2024

The PIR (Passive Infrared) sensor widely used for motion detection applications. This is suitable for low cost motion detection and alarm projects.

This low power PIR sensor detects the movement of human in or out of the sensor range.


Circuit diagram


Here the circuit constructed for to detect the movement and gives beep sound. You can modify the circuit with relay or bulb.

Arduino PIR Sensor sketch code



int pirPin = 2; //digital 2

int buzzerPin = 12; //digital 12

void setup()
pinMode(pirPin, INPUT);
pinMode(buzzerPin, OUTPUT);

void loop()
int pirVal = digitalRead(pirPin);
if(pirVal == HIGH)
{ //was motion detected
Serial.println(“Motion Detected”);
digitalWrite(buzzerPin, HIGH);
else {
digitalWrite(ledPin, LOW);


PIR motion sensor pinout


Components List

S.No Name Quantity
1. Arduino uno 1
2. PIR sensor 1
3. Buzzer 1
4. Connecting wires as required

2 thoughts on “PIR Sensor with Arduino

Leave a Reply

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