#include <Arduino.h>
const int buzzer = 4;
const int melody[] = {
440, 440, 494, 440, 392, 440, 440, 392, 440, 494, 440, 392, 330,
440, 440, 494, 440, 392, 440, 440, 392, 440, 494, 392, 330, 294,
330, 349, 392, 440, 392, 349, 392, 330, 440, 494, 440, 392, 330
};
const int noteDurations[] = {
500, 500, 500, 500, 750, 250, 500, 750, 250, 500, 500, 750, 750,
500, 500, 500, 500, 750, 250, 500, 750, 250, 500, 750, 750, 1000,
500, 500, 500, 500, 750, 250, 500, 750, 250, 500, 500, 750, 1000
};
void setup() {
pinMode(buzzer, OUTPUT);
for (int i = 0; i < sizeof(melody) / sizeof(melody[0]); i++) {
int noteDuration = noteDurations[i];
tone(buzzer, melody[i], noteDuration);
delay(noteDuration);
}
noTone(buzzer);
}
void loop() {
}