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.

PIR-sensor

Circuit diagram

PIR-sensor-circuit

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

[code]

/*www.theorycircuit.com*/

int pirPin = 2; //digital 2

int buzzerPin = 12; //digital 12

void setup()
{
Serial.begin(9600);
pinMode(pirPin, INPUT);
pinMode(buzzerPin, OUTPUT);
}

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

[/code]





PIR motion sensor pinout

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 *