// Potentiometer is connected to GPIO 34 (Analog ADC1_CH6)
//int Buzzer = 7; //for Arduino Microcontroller
//int Buzzer = D7; //for ESP8266 Microcontroller
int Buzzer = 4; //for ESP32 Microcontroller
//const int duration = 500;
const int middle_c = 440;
const int potPin = 34;
// variable for storing the potentiometer value
int potValue = 0;
void setup() {
Serial.begin(115200);
delay(1000);
pinMode (Buzzer, OUTPUT);
}
void loop() {
// Reading potentiometer value
potValue = analogRead(potPin);
Serial.println(potValue);
delay(potValue);
/*digitalWrite (Buzzer, HIGH); //turn buzzer on
delay(potValue);
digitalWrite (Buzzer, LOW); //turn buzzer off
delay(potValue);*/
tone(Buzzer, middle_c, potValue);
delay(potValue);
//
}