void setup() {
pinMode(buzzer, OUTPUT); // set buzzer pin as output
void loop() {
// notes of the song in ascending order
int notes[] = {69, 72, 74, 76, 77, 79, 81, 79, 77, 76, 74, 72, 70, 69};
// duration of each note in milliseconds
int durations[] = {500, 500, 500, 500, 500, 500, 500, 250, 250, 500, 500, 500, 500, 500};
// play the song
for (int i = 0; i < sizeof(notes) / sizeof(notes[0]); i++) {
tone(buzzer, notes[i]);
delay(durations[i]);
noTone(buzzer);
}
}