const int buzzerPin = 9; // Buzzer connected to pin 9
const int potPin = A0; // Potentiometer connected to analog pin A0
void setup() {
pinMode(buzzerPin, OUTPUT); // Set the buzzer pin as an output
pinMode(potPin, INPUT); // Set the potentiometer pin as an input
}
void loop() {
int potValue = analogRead(potPin); // Read the potentiometer value (0 to 1023)
int buzzerFrequency = map(potValue, 0, 1023, 100, 1000); // Map the pot value to a frequency (100Hz to 1000Hz)
tone(buzzerPin, buzzerFrequency); // Output the frequency to the buzzer
delay(10); // Small delay for stability
}