Step-by-Step Instructions
1. Connect the PIR sensor's VCC pin to Arduino 5V and GND to Arduino GND.
2. Connect the PIR sensor's output pin to Arduino digital pin 2.
3. Connect the LED's long leg (anode) to Arduino digital pin 13 through a 220-ohm resistor; connect the short leg (cathode) to GND.
4. Connect the buzzer's positive pin to Arduino digital pin 8 and negative pin to GND.
5. Open Arduino IDE on your computer and write/upload the following code:
```
int pirPin = 2;
int ledPin = 13;
int buzzerPin = 8;
void setup() {
pinMode(pirPin, INPUT);
pinMode(ledPin, OUTPUT);
pinMode(buzzerPin, OUTPUT);
Serial.begin(9600);
}
void loop() {
int motion = digitalRead(pirPin);
if (motion == HIGH) {
digitalWrite(ledPin, HIGH);
tone(buzzerPin, 1000); // 1kHz sound
delay(200);
digitalWrite(ledPin, LOW);
noTone(buzzerPin);
delay(200);
} else {
digitalWrite(ledPin, LOW);
noTone(buzzerPin);
}
}
```
6. Upload the code to the Arduino.
7. Power the Arduino via USB or external supply.
8. Test by moving in front of the PIR sensor; the LED should flash and buzzer sound when motion is detected.