Skip to content

Commit af1803a

Browse files
committed
Update examples
1 parent 45b7d0c commit af1803a

File tree

4 files changed

+268
-364
lines changed

4 files changed

+268
-364
lines changed
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
/*
2+
Play an MP3 over software serial using the MY1690X MP3 IC
3+
By: Nathan Seidle
4+
SparkFun Electronics
5+
Date: December 10th, 2021
6+
License: MIT. See license file for more information but you can
7+
basically do whatever you want with this code.
8+
9+
Feel like supporting our work? Buy a board from SparkFun!
10+
https://www.sparkfun.com/products/18642
11+
12+
Hardware Connections:
13+
MY1690 Pin -> Arduino Pin
14+
-------------------------------------
15+
TXO -> 6
16+
RXI -> 4
17+
3.3V -> 3.3V
18+
GND -> GND
19+
20+
Don't forget to load some MP3s on your sdCard and plug it in too!
21+
*/
22+
23+
#include "SparkFun_MY1690_MP3_Library.h" // Click here to get the library: http://librarymanager/All#SparkFun_MY1690
24+
25+
//For boards that support software serial
26+
#include "SoftwareSerial.h"
27+
SoftwareSerial serialMP3(6, 4); //RX on Arduino connected to TX on MY1690's, TX on Arduino connected to the MY1690's RX pin
28+
29+
//For boards that have multiple hardware serial ports
30+
//HardwareSerial serialMP3(2); //Create serial port on ESP32: TX on 17, RX on 16
31+
32+
MY1690 myMP3;
33+
34+
void setup()
35+
{
36+
Serial.begin(115200);
37+
Serial.println("MY1690 MP3 Example");
38+
39+
serialMP3.begin(9600); //The MY1690 expects serial communication at 9600bps
40+
41+
if (myMP3.begin(serialMP3) == false) // Beginning the MP3 player requires a serial port (either hardware or software)
42+
{
43+
Serial.println("Device not detected. Check wiring. Freezing.");
44+
while (1);
45+
}
46+
47+
int songCount = myMP3.getSongCount();
48+
if (songCount == 0)
49+
{
50+
Serial.println("Oh no! No songs found. Try adding songs or plugging in the sd card. Freezing.");
51+
while (1);
52+
}
53+
54+
Serial.print("Number of tracks on SD card: ");
55+
Serial.println(songCount);
56+
57+
myMP3.setVolume(25); //Max of 30
58+
59+
myMP3.play(); //Will play the lowest numbered song in the folder
60+
}
61+
62+
void loop()
63+
{
64+
65+
}

examples/Example1_Terminal_MP3_Player/Example1_Terminal_MP3_Player.ino

Lines changed: 0 additions & 230 deletions
This file was deleted.

0 commit comments

Comments
 (0)