-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathharkTheHerald.h
47 lines (38 loc) · 1.03 KB
/
harkTheHerald.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
// Based on https://learn.adafruit.com/circuit-playground-music/the-sound-of-music and https://hymnary.org/media/fetch/100411
#include "pitches.h"
const int melody[] = {
NOTE_C5, NOTE_F5, NOTE_F5, NOTE_E5,
NOTE_F5, NOTE_A5, NOTE_A5, NOTE_G5,
NOTE_C6, NOTE_C6, NOTE_C6, NOTE_AS5,
NOTE_A5, NOTE_G5, NOTE_A5,
NOTE_C6, NOTE_C6, NOTE_C6, NOTE_F5,
NOTE_AS5, NOTE_A5, NOTE_A5, NOTE_G5,
NOTE_C6, NOTE_C6, NOTE_C6, NOTE_F5,
NOTE_AS5, NOTE_A5, NOTE_A5, NOTE_G5,
NOTE_D6, NOTE_D6, NOTE_D6, NOTE_C6,
NOTE_AS5, NOTE_A5, NOTE_AS5,
NOTE_G5, NOTE_A5, NOTE_AS5, NOTE_C6, NOTE_F5,
NOTE_F5, NOTE_G5, NOTE_F5
};
const float rhythm[] = {
4, 4, 2.6, 8,
4, 4, 4, 4,
4, 4, 2.6, 8,
4, 4, 2,
4, 4, 4, 4,
4, 4, 4, 4,
4, 4, 4, 4,
4, 4, 4, 4,
4, 4, 4, 4,
4, 4, 2,
4, 8, 8, 2.6, 8,
4, 4, 2
};
const int numNotes = 46;
void doHarkTheHerald() {
for (int i = 0; i < numNotes; i++) {
int noteDuration = 1000 / rhythm[i];
CircuitPlayground.playTone(melody[i], noteDuration);
delay(noteDuration * 0.20);
}
}