//define the pins
#define PIRPin 2
#define BuzzerPin 3
#define LEDPin 4
void setup() {
// put your setup code here, to run once:
// setup in modes for the peripheral devices
pinMode(PIRPin, INPUT);
pinMode(BuzzerPin, OUTPUT);
pinMode(LEDPin, OUTPUT);
}
void loop() {
// put your main code here, to run repeatedly:
// if motion is detected PIRPin will go HIGH
if(digitalRead(PIRPin)==HIGH){
// Activate alarm and LED
digitalWrite(LEDPin, HIGH);
digitalWrite(BuzzerPin, HIGH);
delay(3000);
digitalWrite(LEDPin, LOW);
digitalWrite(BuzzerPin, LOW);
}
}