int buzer = 34; // Replace 36 with your desired analog pin number
int boton = 35;
int led = 14;
int vb = 0;
void setup() {
pinMode(buzer, OUTPUT);
pinMode(boton, INPUT_PULLUP); // Add pull-up resistor for better button input
pinMode(led, OUTPUT);
}
void loop() {
vb = analogRead(boton); // Read analog value from button
if (vb > 800) { // Adjust threshold based on your button's resistance
for (int i = 0; i < 10; i++) {
delay(200);
tone(buzer, 220, 100); // Use the ESP32Tone library for tone generation
digitalWrite(led, HIGH);
delay(200);
noTone(buzer);
digitalWrite(led, LOW);
}
}
}