int buzzerPin = 8;
int c = 262;
int d = 294;
int e = 330;
int f = 349;
int g = 392;
int a = 440;
int b = 494;
int C = 523;
int melody[] = { c, c, g, g, a, a, g, f, f, e, e, d, d, c, g, g, f, f, e, e, d, g, g, f, f, e, e, d, c, c, g, g, a, a, g, f, f, e, e, d, d, c };
int noteDurations[] = { 500, 500, 500, 500, 500, 500, 1000, 500, 500, 500, 500, 500, 500, 1000, 500, 500, 500, 500, 500, 500, 1000, 500, 500, 500, 500, 500, 500, 1000, 500, 500, 500, 500, 500, 500, 1000, 500, 500, 500, 500, 500, 500, 1000 };
void setup() {
Serial.begin(9600);
}
void loop() {
int notes = sizeof(melody) / sizeof(melody[0]);
for (int i = 0; i < notes; i = i + 1) {
tone(buzzerPin, melody[i], noteDurations[i]);
delay(noteDurations[i] * 1.30);
noTone(buzzerPin);
}
}