int buttonPin = 15;
int buzzerPin = 13;
int buttonState = 0;
void setup() {
pinMode(buttonPin, INPUT_PULLUP);
pinMode(buzzerPin, OUTPUT);
}
void loop() {
buttonState = digitalRead(buttonPin);
if (buttonState == LOW) {
tone(buzzerPin, 1000); // play 1000Hz tone
} else {
noTone(buzzerPin); // stop tone
}
}