#include "pitches.h"
// Define the buzzer pin
const int buzzerPin = 23;
// Define the duration of each note (in milliseconds)
const int noteDuration = 500;
// Define the Bollywood-style melody
int bollywoodMelody[] = {
NOTE_D5, NOTE_E5, NOTE_FS5, NOTE_A5,
NOTE_A5, NOTE_FS5, NOTE_E5, NOTE_D5,
NOTE_E5, NOTE_D5, NOTE_E5, NOTE_FS5,
NOTE_A5, NOTE_A5, NOTE_A5, NOTE_A5,
NOTE_D6, NOTE_D6, NOTE_D6, NOTE_D6,
NOTE_D6, NOTE_E6, NOTE_D6, NOTE_FS6,
NOTE_A6, NOTE_A6, NOTE_FS6, NOTE_E6,
NOTE_D6, NOTE_E6, NOTE_D6, NOTE_FS6
};
// Define the simple melody
int simpleMelody[] = {
NOTE_C4, NOTE_E4, NOTE_G4, NOTE_C5,
NOTE_G4, NOTE_E4, NOTE_C4, NOTE_G4,
NOTE_C4, NOTE_E4, NOTE_G4, NOTE_C5,
NOTE_G4, NOTE_E4, NOTE_C4, NOTE_G4
};
// Define the "Come September" tune
int comeSeptemberMelody[] = {
659, 659, 0, 659, 0, 523, 659, 0, 784, 0, 0, 880,
// ... (complete the rest of the "Come September" melody)
};
void playMelody(int melody[]) {
for (int i = 0; i < sizeof(melody) / sizeof(melody[0]); i++) {
if (melody[i] != 0) {
tone(buzzerPin, melody[i], noteDuration);
delay(noteDuration * 1.1); // Pause between notes
} else {
noTone(buzzerPin);
delay(noteDuration * 1.1); // Pause between notes
}
}
}
void setup() {
// Set the buzzer pin as an output
pinMode(buzzerPin, OUTPUT);
}
void loop() {
playMelody(bollywoodMelody);
delay(500); // Pause between melodies
playMelody(simpleMelody);
delay(700); // Pause between melodies
playMelody(comeSeptemberMelody);
delay(1000); // Pause before repeating the melodies
}