int piezoPin = 8; int potPin = A0;
void setup() {
}
void loop() {
int potValue = analogRead(potPin); // Read from 0
int frequency = map(potValue, 0, 1023, 100, 1000);
tone(piezoPin, frequency); // Play tone at the
delay(20); // Small delay to reduce buzzing
}