#define SPEAKER_PIN 8
// Define the frequencies of the notes (in Hertz)
const int sa = 261; // C4
const int re = 293; // D4
const int ga = 329; // E4
const int ma = 349; // F4
const int pa = 392; // G4
const int dha = 440; // A4
const int ni = 493; // B4
const int sa_high = 523; // C5
// Define the duration of each beat (in milliseconds)
const int beatDuration = 500;
void setup() {
pinMode(SPEAKER_PIN, OUTPUT);
}
void loop() {
playTone(sa, beatDuration);
playTone(re, beatDuration);
playTone(ga, beatDuration);
playTone(ma, beatDuration);
playTone(pa, beatDuration);
playTone(dha, beatDuration);
playTone(ni, beatDuration);
playTone(sa_high, beatDuration);
// Pause before repeating the sequence
delay(2000);
}
void playTone(int frequency, int duration) {
tone(SPEAKER_PIN, frequency, duration);
delay(duration);
noTone(SPEAKER_PIN); // Ensure the speaker is turned off between notes
delay(50); // Short pause between notes
}