#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 melody[] = {
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
};
void setup() {
// Set the buzzer pin as an output
pinMode(buzzerPin, OUTPUT);
}
void loop() {
// Iterate through the melody and play each note
for (int i = 0; i < sizeof(melody) / sizeof(melody[0]); i++) {
// Calculate the note duration
int duration = noteDuration;
// If the note is a rest, pause for the calculated duration
if (melody[i] == 0) {
delay(duration);
} else {
// Play the note on the buzzer
tone(buzzerPin, melody[i], duration);
// Pause for a short time between notes
delay(50);
}
}
// Pause for 60 seconds
delay(60000);
}