int PIRSensor = 2;
int Buzzer = 5;
int LED = 4;
int SensorValue = 0;
void setup() {
pinMode(Buzzer, OUTPUT);
pinMode(LED, OUTPUT);
pinMode(PIRSensor, INPUT);
Serial.begin(9600);
}
void loop() {
SensorValue = digitalRead(PIRSensor);
if (SensorValue == HIGH){
digitalWrite(LED, HIGH);
tone(Buzzer, 5000);
Serial.println("Motion Detected");
}
else
{
digitalWrite(LED, LOW);
noTone(Buzzer);
Serial.println("Motion not Detected");
}
}