// Connect the BUZZER on PIN 19
#define LED_PIN 17
#define PIR_PIN 25
bool motionDetected = false;
void setup() {
Serial.begin(115200);
Serial.println("Hello, ESP32!");
pinMode(PIR_PIN, INPUT);
pinMode(LED_PIN, OUTPUT);
// Set BUZZER pinMode to OUTPUT
digitalWrite(LED_PIN, LOW);
// Initially set Buzzer to off
}
void loop() {
motionDetected = digitalRead(PIR_PIN);
// Check whether motion is detected or not and buzz the Buzzer
if(motionDetected){
digitalWrite(LED_PIN, HIGH);
}else{
digitalWrite(LED_PIN, LOW);
}
delay(1000);
}