int buzzPin = 13; // Set the pin for the buzzer
int noteDuration = 200; // Set note duration in milliseconds
int notes[] = { 659, 659, 0, 659, 0, 523, 659, 0, 784, 0, 392, 0, 523, 0, 392, 0, 330, 0, 440, 0, 494, 0, 466, 0, 440, 0, 392, 0, 659, 0, 784, 0, 880, 0, 698, 0, 784, 0, 659, 0, 523, 0, 587, 0, 494, 0, 523, 0, 392, 0, 330, 0, 440, 0, 494, 0, 466, 0, 440, 0, 392, 0 };
void setup() {
pinMode(buzzPin, OUTPUT); // Set the buzzer pin as an output
}
void playNote(int note, int duration) {
tone(buzzPin, note, duration);
delay(duration);
noTone(buzzPin);
}
void loop() {
for (int i=0; i<53; i++) {
if (notes[i] == 0) {
// Set a pause
delay(noteDuration);
} else {
// Play the note
playNote(notes[i], noteDuration);
}
}
delay(0.1); // Wait 5 seconds before repeating the song
}