You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: examples/Example1_PlayFile/Example1_PlayFile.ino
+169-7Lines changed: 169 additions & 7 deletions
Original file line number
Diff line number
Diff line change
@@ -6,6 +6,9 @@
6
6
License: MIT. See license file for more information but you can
7
7
basically do whatever you want with this code.
8
8
9
+
The MY1690 has a large number of features. This example presents the user
10
+
with a serial menu to control the various aspects of the IC.
11
+
9
12
Feel like supporting our work? Buy a board from SparkFun!
10
13
https://www.sparkfun.com/products/18642
11
14
@@ -18,13 +21,14 @@
18
21
GND -> GND
19
22
20
23
Don't forget to load some MP3s on your sdCard and plug it in too!
24
+
Note: Track must be named 0001.mp3 to myMP3.playTrackNumber(1)
21
25
*/
22
26
23
27
#include"SparkFun_MY1690_MP3_Library.h"// Click here to get the library: http://librarymanager/All#SparkFun_MY1690
24
28
25
29
//For boards that support software serial
26
30
#include"SoftwareSerial.h"
27
-
SoftwareSerial serialMP3(5, 2); //RX on Arduino connected to TX on MY1690's, TX on Arduino connected to the MY1690's RX pin; format: SoftwareSerial mySerial(rx, tx)
31
+
SoftwareSerial serialMP3(2, 3); //RX on Arduino connected to TX on MY1690's, TX on Arduino connected to the MY1690's RX pin
28
32
29
33
//For boards that have multiple hardware serial ports
30
34
//HardwareSerial serialMP3(2); //Create serial port on ESP32: TX on 17, RX on 16
@@ -34,32 +38,190 @@ MY1690 myMP3;
34
38
voidsetup()
35
39
{
36
40
Serial.begin(115200);
37
-
Serial.println("MY1690 MP3 Example");
41
+
Serial.println(F("MY1690 MP3 Example"));
38
42
39
43
serialMP3.begin(9600); //The MY1690 expects serial communication at 9600bps
40
-
44
+
41
45
if (myMP3.begin(serialMP3) == false) // Beginning the MP3 player requires a serial port (either hardware or software)
42
46
{
43
-
Serial.println("Device not detected. Check wiring. Freezing.");
47
+
Serial.println(F("Device not detected. Check wiring. Freezing."));
44
48
while (1);
45
49
}
46
50
47
51
int songCount = myMP3.getSongCount();
48
52
if (songCount == 0)
49
53
{
50
-
Serial.println("Oh no! No songs found. Try adding songs or plugging in the sd card. Freezing.");
54
+
Serial.println(F("Oh no! No songs found. Make sure the SD card is inserted and there are MP3s on it. Freezing."));
51
55
while (1);
52
56
}
53
57
54
-
Serial.print("Number of tracks on SD card: ");
58
+
Serial.print(F("Number of tracks on SD card: "));
55
59
Serial.println(songCount);
56
60
57
-
myMP3.setVolume(25); //Max of 30
61
+
Serial.print(F("MY1690 Version: "));
62
+
Serial.println(myMP3.getVersion());
58
63
59
64
myMP3.play(); //Will play the lowest numbered song in the folder
65
+
66
+
//It takes ~30ms for a track to start playing. If we check immediately, the track has not yet started.
0 commit comments