playing sound without pc serial monitor

Hello everyone

I'm new to the forum, and this is my first post so hopefully its done properly and in the correct location. I've pretty new to Arduino as well and have run into an issue that has me totally stuck. I have a catalex yx5300 serial mp3 player. I've looked at online code and tutorials and all that I've seen exclusively use the serial monitor and USB to send/receive. I'm trying to make so, without the usb or serial monitor, I can press a remote button and the song plays from the headphones attached to the mp3 player.

First question is...is that possible to do? I was thinking that sending the direct command via Serial1 (I'm using a Mega board) would work using either Serial1.write or Serial1.print. Neither have worked. I've tried breaking down the command code (from the mp3 player manual) into multiple lines, making it into one line, 0x's in front of each section, spaces, no spaces, etc. Is my logical process incorrect, meaning, I need to do more than simply command the mp3 player to play? Do I need to add code to return data from the mp3 player?

I have attached two different instances of my code to this post. It more than likely is considered suboptimal, but the remote and 1 digit 7 segment display do work. I also know that the headphones and mp3 player work, because I tried an online example and they work as well. So I think the problem has to be with my code and logic and just leaving something out. I'm pretty much out of options and at my wit's end, so any and all help would be greatly appreciated. Thank you all very much.

playinaround.ino (2.58 KB)

playinaround2.ino (2.95 KB)

First question is...is that possible to do?

Yes I would think so.

I've tried breaking down the command code (from the mp3 player manual) into multiple lines, making it into one line, 0x's in front of each section, spaces, no spaces, etc, is my logical process incorrect,

Yes it sounds like you haven't got a clue about what you are doing.

It is a wast of time looking at the code before we can see a schematic of how you have everything connected up. Only with a schematic does code make sense.

Please read this:-
How to use this forum it will tell you about posting stuff as well as posting code correctly.

Thank you for the feedback. I created a fritzing breadboard image and schematic, which should be in the attachments. Here is the code I have so far:

include <IRremote.h>
//program for Mega2560 board, so Serial1 is used
const int RECV_PIN = 7;
IRrecv irrecv(RECV_PIN);
decode_results results;

const int  a = 22; //connected to pin a of 7-segment display
const int  b = 23; //connected to pin b of 7-segment display
const int  c = 24; //connected to pin c of 7-segment display
const int  d = 25; //connected to pin d of 7-segment display
const int  e = 26; //connected to pin e of 7-segment display
const int  f = 27; //connected to pin f of 7-segment display
const int  g = 28; //connected to pin g of 7-segment display
const int  dp = 29; //connected to pin dp of 7-segment display

void setup(){
  irrecv.enableIRIn();
  irrecv.blink13(true);
Serial1.begin(9600);
delay(500);
Serial1.print('0x7e');
Serial1.print("0xff");
Serial1.print("0x06");//initialize card...hopefully???
Serial1.print("0x09");
Serial1.print("0x00");
Serial1.print("0x00");
Serial1.print("0x02");
Serial1.print("0xef");
}

void loop(){
    if (irrecv.decode(&results)){

        switch(results.value){
          case 0xFF30CF: //Keypad button "1"
          
          digitalWrite(b,HIGH);//display1
          digitalWrite(c,HIGH);//display1
          Serial1.print("0x7e");//attempting to use hexcode to play first audio file on sd card
          Serial1.print("0xff");//just trying
          Serial1.print("0x06");//to break it
          Serial1.print("0x22");//into
          Serial1.print("0x00");//little
          Serial1.print("0x1e");//one
          Serial1.print("0x01");//byte
          Serial1.print("0xef");//pieces
          delay(8500);//length of sound file if it properly plays
          
          digitalWrite(b, LOW);//clears display1
          digitalWrite(c, LOW);//clears display1
          }

        switch(results.value){
          case 0xFF18E7: //Keypad button "2"

          digitalWrite(a,HIGH);
          digitalWrite(b,HIGH);
          digitalWrite(g,HIGH);
          digitalWrite(e,HIGH);
          digitalWrite(d,HIGH);//these display 2
          Serial1.print("7eff060d010000ef"); //another attempt to use hexcode to play first file on sd card
          delay(8500);//length of sound file if it properly plays

          digitalWrite(a,LOW);
          digitalWrite(b,LOW);
          digitalWrite(g,LOW);
          digitalWrite(e,LOW);
          digitalWrite(d,LOW);//these clear display number 2
          }
          
        switch(results.value){
          case 0xFF7A85: //Keypad button "3"

          digitalWrite(a,HIGH);
          digitalWrite(b,HIGH);
          digitalWrite(c,HIGH);
          digitalWrite(d,HIGH);
          digitalWrite(g,HIGH);//these display number 3
          Serial1.write("7E FF 06 22 00 1E 01 EF");//another hexidecimal attempt to play first file
          delay(8500);//length of sound file if it properly plays
          digitalWrite(a,LOW);
          digitalWrite(b,LOW);    
          digitalWrite(c,LOW);
          digitalWrite(d,LOW);
          digitalWrite(g,LOW);//these clear number 3

          }
          switch(results.value){
          case 0xFF10EF: //Keypad button "4"

          digitalWrite(f,HIGH);
          digitalWrite(b,HIGH);
          digitalWrite(g,HIGH);
          digitalWrite(c,HIGH);//these display number 4
          Serial1.print("0X7E 0XFF 0X06 0X22 0X00 0X1E 0X01 0XEF");//another hexidecimal attempt to play first file
          delay(8500);//length of sound file if it properly plays
          digitalWrite(f,LOW);
          digitalWrite(b,LOW);
          digitalWrite(g,LOW);
          digitalWrite(c,LOW);//these clear display number 4
  
          }
        irrecv.resume(); 
    }
}

OK let's get your hardware right first.
You have no common ground. The ground on the Arduino, MP3 player and circuit on the bread board must all be connected together.

Next you have no current limiting resistors in the seven segment display you need a resistor for each segment.
I would drop the display and the IR detector from your code and just get the MP3 player working first before getting fancy. When you do get round to the IR part then get the data sheet and see how to wire it to the power supply, you need resistors and a capacitor to make it work reliably.

I can't actually see an MP3 player on that "schematic". Now you are probably going to say it is because Ftrizing doesn't have one, which is why we don't like schematics like this here. You are much better off with a hand drawn thing and posting a photograph. Label all the wires from the boxes with a name and pin number but put the pin numbers in a place that minimises the length and number of crossings of the wires.

on the board in real life, I had everything grounded, though everything did not have a common ground (very good to know, and it does make sense). I updated it on Fritzing.

I did not place resistors on the display due to not being able to find a spot for the resistors because of the pin placement on the 7 segment display. I've read that its a best practice to do this so the display does not burn out, so I lowered the voltage to 3.3 (though 5v is fairly dim as well, probably due to sharing with the IR). At this point, are resistors necessary even if the voltage is shared between multiple parts?

You are correct, i don't have an offical mp3 player on the schematic. To try to save time I used the 'mystery part' option and added and described the pins, and gave the correct model number catalex yx5300. I know its suboptimal, but my hope was that it would get me by. As you can tell, I've never done this before, so I flocked to the simplest program to use and shared the breadboard and schematic. If/when I get the chance to create a hand written schematic, I will share it here.

I've read that its a best practice to do this so the display does not burn out, so I lowered the voltage to 3.3

LEDs are none linear devices, so you can’t just do that. The LED needs a higher voltage than its forward voltage but also needs a current limiting circuit, and a resistor is the simplest form of current limiting device.

The fact you couldn’t find space to add one on your layout doesn’t change the laws of Physics.

are resistors necessary even if the voltage is shared between multiple parts?

Yes, there is no mitigating condition.

You are correct, i don't have an offical mp3 player on the schematic. To try to save time I used the 'mystery part' option

That is the number two reason why the pile of useless crap that is Fritzing is disliked on this forum. The number one reason is that any none trivia circuit is impossible to read. Followed by the number three reason that people say “yes that was not on my diagram but in real life it is.”

If/when I get the chance to create a hand written schematic, I will share it here.

Good I will look forwards to being in a position to give you help when / if you do.