#define BUZZER_PIN 4
#define BUTTON_PIN 2
#define NOTE_C5 523
void setup() {
pinMode(BUTTON_PIN, INPUT_PULLUP);
pinMode(BUZZER_PIN, OUTPUT);
}
void loop() {
if (!digitalRead(BUTTON_PIN)) {
tone(BUTTON_PIN, NOTE_C5);
} else {
noTone(BUTTON_PIN);
}
delay(10); // this speeds up the simulation
}