#define PIR_PIN 15
#define BUZZER_PIN 13
void setup() {
pinMode(PIR_PIN, INPUT);
pinMode(BUZZER_PIN, OUTPUT);
Serial.begin(115200);
Serial.println("BARISAN JUANG");
}
void loop() {
int motionDetected = digitalRead(PIR_PIN);
if (motionDetected == HIGH) {
tone(BUZZER_PIN, 1000); // Buzzer on with 1kHz tone
Serial.println("ADA PERGERAKAN!");
delay(1000); // Delay to keep the tone for a short time
noTone(BUZZER_PIN); // Turn off the buzzer
} else {
noTone(BUZZER_PIN); // Ensure buzzer is off
Serial.println("TIDAK ADA PERGERAKAN.");
}
delay(500);
}