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
[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
Components List
S.No | Name | Quantity |
1. | Arduino uno | 1 |
2. | PIR sensor | 1 |
3. | Buzzer | 1 |
4. | Connecting wires | as required |
Metal sensor, gsm, pir sensor, camera , connected in adrino 328p
else {
digitalWrite(ledPin, LOW);
not good 🙂
else {
digitalWrite(buzzerPin, LOW);
is good 🙂