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4, 4, 4,8,4, 7, 4,8,8,1.5,8,
2,2,8,8,7,16,4,7,16,3,8,4,4,1.5
};
void setup() {
for (int thisNote = 0; thisNote < 93; thisNote++) {
int noteDuration = 2000 / noteDurations[thisNote];
tone(9, melody[thisNote], noteDuration);
// to distinguish the notes, set a minimum time between them.
// the note's duration + 30% seems to work well:
int pauseBetweenNotes = noteDuration * 1.30;
delay(pauseBetweenNotes);
// stop the tone playing:
noTone(9);
}
}
void loop() {
// no need to repeat the melody.
}