int PIR = 14;
int buzz = 19;
void setup() {
// put your setup code here, to run once:
Serial.begin(115200);
Serial.println("Hello, ESP32!");
pinMode(PIR, INPUT);
pinMode(21, OUTPUT);
pinMode(buzz, OUTPUT);
}
void loop() {
int Reading =digitalRead(PIR);
Serial.println(Reading);
if (Reading==1)
{
digitalWrite(21, HIGH);
tone(buzz,250);
}
else
{
digitalWrite(21, LOW);
noTone(buzz);
}
delay(10); // this speeds up the simulation
}