const int potPin = A0; // Analog pin for potentiometer
const int buzzerPin = 11; // Digital pin for buzzer
const int threshold = 512; // Adjust this threshold value according to your setup
void setup() {
pinMode(potPin, INPUT);
pinMode(buzzerPin, OUTPUT);
Serial.begin(9600);
}
void loop() {
int potValue = analogRead(potPin); // Read the analog value from the potentiometer
Serial.println(potValue);
if (potValue > threshold) {
tone(buzzerPin, 1000); // Make a sound if the analog value is greater than the threshold
} else {
noTone(buzzerPin); // Stop making sound if the analog value is lower than the threshold
}
}