Help with programming Arduino Catalex MP3 Module

Hello, I’m a beginner to arduino coding and have been trying to program an arduino catalex (MD_YX5300) using majicdesigns library for it. I’m trying to use a shake sensor to play an mp3 file off of the catalex but my current code doesn’t work. Please assist me in trying to do this as I suspect I have no clue how to do this properly.

This is the code so far:

#include <MD_YX5300.h>
Int sensor;
const short rx = 6;
const short tx = 5;
MD_YX5300 mp3(rx, tx);

void setup()
{
Serial.begin(9600);
Serial.println(mp3.playStart());

mp3.begin();
mp3.setSynchronous(true);
mp3.volumeDec();
}

void loop()
{
sensor = analogRead(A0);
if (sensor<1022){
mp3.playNext();
}

mp3.check();

Hi Chimp,

At GitHub where most of all Arduino-libraries have their repository
there is a subflder examples. You can use these examples as a starting point. I would recommend the example-code
"MD_YX5300_Test"

Tinkering with microcontrollers has always two sides:

  1. hardware and
  2. software. You should test your hardware with a democode that is well known for that the code works.

If you have a question about the democode even if it is the first line of the democode. You are welcome to ask all these questions.

By asking such a question about a line of code of a program you
show that you really deal with it. If this can be seen you will always get answers.

best regards Stefan

1 Like

.begin() must always be the first thing you call in the library. Then you can do everything else.

There is a lot of documentation for this library (look at the docs folder and open index.html) as well as example code that you can follow.

1 Like

Thank you both very much. I think the “simple player” demo code seems to work best for my project. Thanks for assisting!

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.