const int BUZZER_PIN = 13;
const int PIR_PIN = 10;
void setup() {
// put your setup code here, to run once:
pinMode(BUZZER_PIN, OUTPUT);
pinMode(PIR_PIN, INPUT);
}
void loop() {
// put your main code here, to run repeatedly:
int intruderDetected = digitalRead(PIR_PIN);
// If intruder detected, sound the buzzer
if (intruderDetected == HIGH) {
// tone(SPEAKER_PIN, 1000);
digitalWrite(BUZZER_PIN, HIGH);
} else {
// noTone(SPEAKER_PIN);
digitalWrite(BUZZER_PIN, LOW);
}
}