//below line Because we have connected the Buzzer with pin 12 of the Arduino.
int Buzzerpin = 12;
void setup() {
// put your setup code here, to run once:
pinMode(Buzzerpin,OUTPUT);
}
void loop() {
//analogRead() function help to read voltage value from the specified analog pin
int value = analogRead(A0);
digitalWrite(Buzzerpin, HIGH); //HIGH to make the buzzer ON
tone(Buzzerpin, value); // the buzzer will ring as per voltage value.
delay(value);
digitalWrite(Buzzerpin, LOW); // LOW to make the buzzer OFF
delay(value);
Serial.println(value); //PRINT on consolue
}