const int buttonPin = 11; // Pin number where the button is connected
void setup() {
pinMode(buttonPin, INPUT); // Set the button pin as an input
pinMode(A0, OUTPUT); // Set the buzzer pin as an output
pinMode(A5, OUTPUT);
tone(A0, 1000, 2000);
}
void loop() {
int buttonState = digitalRead(buttonPin); // Read the state of the button
if (buttonState == HIGH) { // If the button is pressed
pinMode(A5, OUTPUT);
analogWrite(A5, 150); // G4
delay(100);
} else if (buttonState == LOW) {
pinMode(A5, INPUT);
analogWrite(A5, 0); // G4
delay(100);
}
}