COMPONENTS-
Arduino UNO R3 X 1
LED X 1
PIR motion Sensor X 1
How Does the Motion-Sensor Alarm Work?
Here, we are using a PIR motion sensor. This motion sensor consists of a fresnel lens, an infrared detector, and supporting detection circuitry. The lens on the sensor focuses any infrared radiation present around it toward the infrared detector. Our bodies generate infrared heat, and this heat is detected by the motion sensor. The sensor outputs a 5V signal for a period of one minute as soon as it detects the presence of a person. It offers a tentative range of detection of about 6–7m and is highly sensitive.
CODE-
#define pir 2
void setup()
{
pinMode(13,OUTPUT);
pinMode(pir,INPUT);
}
void loop()
{
int data=digitalRead(pir);
if(data==1)
{
digitalWrite(13,HIGH)
}
else
digitalWrite(9,LOW);
}
*if there is any problem making this project please feel free to comment