Motion Detection Using PIR Motion Sensor

PIR is known as Passive Infrared sensor. It detects motions of all objects with a temperature above Absolute Zero (0 Kelvin / -273.15 °C) emit heat energy in the form of infrared radiation, including human bodies. The hotter an object is, the more radiation it emits. PIR sensor is specially designed to detect such levels of infrared radiation.    

PIR Pinout

Requirements

  1. Arduino UNO
  2. PIR Sensor
  3. Piezo Buzzer
  4. Breadboard (optional)
  5. Jumper wires

Schematics

Code

				
					int sensorState = 0;
void setup()
{
  pinMode(2, INPUT);
  pinMode(13, OUTPUT);
  Serial.begin(9600);
}
void loop()
{
  // read the state of the sensor/digital input
  sensorState = digitalRead(2);
 // check if sensor pin is HIGH. if it is, set the LED on.
  if (sensorState == HIGH) {
    digitalWrite(13, HIGH);
    Serial.println("Sensor activated!");
  } 
else {    digitalWrite(13, LO
W);
  }
  delay(10); // Delay a little bit to improve simulation performance
}
				
			

Conclusion

The buzzer will turn on as the PIR sensor detects a motion

Leave a Reply

Your email address will not be published.