-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy path6_jukebox_player.cpp
53 lines (44 loc) · 920 Bytes
/
6_jukebox_player.cpp
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
48
49
50
51
52
53
#include <Arduino.h>
#include <TonePlayer.h>
#include <PiezoSpeaker.h>
#include <RTTTL.h>
PiezoSpeaker speaker1 = PiezoSpeaker(PC0, 50, 0);
TonePlayer player;
const char *songs[] = {
RTTTL_PINK_PANTHER,
RTTTL_SIMPSONS,
RTTTL_USA,
RTTTL_SUPER_MARIO_BROS,
RTTTL_SUPER_MARIO_BROS_POLY,
RTTTL_WALES,
RTTTL_FRANCE,
RTTTL_CROATIA
};
int song_index = 0;
int song_count = sizeof(songs) / sizeof(char *);
void setup()
{
Serial.begin(115200);
delay(750);
Serial.println(F("** JUKEBOX PLAYER **"));
player.attachSpeaker(&speaker1);
Song *song = parseRTTL(songs[song_index]);
player.play(song);
}
void loop()
{
if (player.isPlaying())
{
player.loop();
}
else
{
Serial.println("\nFinished");
delay(2000);
song_index++;
if (song_index > song_count - 1)
song_index = 0;
Song *song = parseRTTL(songs[song_index]);
player.play(song);
}
}