Help with HiLetgo MP3 Module

My brother is a toy maker and I'm building a circuit to animate a prototype toy for his business.

One of the component features of this toy is it will play an mp3 soundtrack while the device rotates on a base and is lit up from the interior. I have the motor and LED system working, but I'm having an issue with the mp3 portion of the circuit.

The mp3 player I bought for this project is: HiLetgo 2pcs mp3 Player Mini MP3 Player Audio Voice Module TF Card U Disk Board for DFPlayer Audio Voice Music Module.

I think the mp3 module I bought fits this post:

https://forum.arduino.cc/t/df-player-warning/952842

https://www.amazon.com/gp/product/B01D1D0E7Q/ref=ox_sc_saved_title_6?smid=A30QSGOJR8LMXA&psc=1

I can get the mp3 module to play, skip tracks, change volume, etc., by manually connecting the IO1 and IO2 pins to ground, but I can't seem to program it to perform these actions via the sketch.

For now, this is the basic order of operations:

Turn the power on and the sketch should automatically start playing a predetermined mp3 file, the toy begins to rotate on its base, and the LED lights up the interior of the toy.

Press the button once, toy continues to turn and LED remains lit, but mp3 changes tracks to a second predetermined track.

Press the button a second time, the toy continues to turn and the LED remains lit, but the mp3 changes tracks to a third predetermined track.

Press the button a fourth time, and the toy stops turning, the LEDs turn off, and the mp3 plays the "shut down" track.

I suppose this order of operations isn't all that important, as I can program it to do what I want once I understand how to get the mp3 to start playing.

I've learned that this particular mp3 player is one that requires a custom library, but I can't seem to find the library I need online, so I guess my question is a two-parter - can you tell me where I can find this library? Can I make this work using the libraries I included in the sketch?

Please see the sketch below.

Thank you in advance for any help you can offer.

#include "SoftwareSerial.h"
#include "DFRobotDFPlayerMini.h"
#include "mp3tf16p.h"
//#include "debounce.h"

//Named constants for the project.
static const uint8_t PIN_MP3_TX = 2; //Pin number for MP3 Transmit.
static const uint8_t PIN_MP3_RX = 3; //Pin number for MP3 Receive.
const int mp3DownPin = 5; //Pin number for MP3 "Previous Track" & "Volume Down." Short press for previous track; long press for volume down.
const int mp3UpPin = 6; //Pin number for MP3 "Next Track" & "Volume Up." Short press for next track; long press for volume up.
const int ledPin = 7; //Pin number for Qi-powered LED module.
const int motorPin = 8; //Pin number for motor.
const int buttonPin = 12; //Pin number for selection switch.

int buttonState;
int lastButtonState = LOW;
int ledState = LOW;
int motorState = LOW;
int mp3DownState = HIGH;
int mp3UpState = HIGH;

unsigned long lastDebounceTime = 0;
unsigned long debounceDelay = 50;

SoftwareSerial softwareSerial(PIN_MP3_RX, PIN_MP3_TX);

//DFRobotDFPlayerMini myDFPlayer;

void setup() {
  // put your setup code here, to run once:

  pinMode(buttonPin, INPUT); //Initialize the "Button" pin as an input.
  pinMode(mp3DownPin, OUTPUT); //Initialize the "MP3 Down" pin as an output.
  pinMode(mp3UpPin, OUTPUT); //Initialize the "MP3 Up" pin as an output.
  pinMode(ledPin, OUTPUT); //Initialize the "LED" pin as an output.
  pinMode(motorPin, OUTPUT); //Initialize the "Motor" pin as an output.

  digitalWrite(mp3DownPin, mp3DownState);
  digitalWrite(mp3UpPin, mp3UpState);
  digitalWrite(ledPin, ledState);
  digitalWrite(motorPin, motorState);
 
}

void loop() {
  // put your main code here, to run repeatedly:

  int reading = digitalRead(buttonPin);

  if (reading != lastButtonState) {
    lastDebounceTime = millis();
  }

  if ((millis() - lastDebounceTime) > debounceDelay) {
    if (reading != buttonState) {
      buttonState = reading;
      if (buttonState == HIGH) {
        ledState = !ledState;
        motorState = !motorState;
        mp3DownState = !mp3DownState;
      }
    }
  }

  digitalWrite(ledPin, ledState);
  digitalWrite(motorPin, motorState);
  //myDFPlayer.play(1);

  lastButtonState = reading;
}

You didn't note which 'Arduino' you are using.
https://github.com/DFRobot/DFRobotDFPlayerMini/blob/master/examples/FullFunction/FullFunction.ino

This is my DFPlayer basic test--

#include "SoftwareSerial.h"
#include "DFRobotDFPlayerMini.h"

// Use pins 2 and 3 to communicate with DFPlayer Mini
static const uint8_t PIN_MP3_TX = 2; // Connects to module's RX 
static const uint8_t PIN_MP3_RX = 3; // Connects to module's TX 

SoftwareSerial softwareSerial(PIN_MP3_RX, PIN_MP3_TX);

// Create the Player object
DFRobotDFPlayerMini player;

void setup() 
{
  Serial.begin(19200);
  delay(500);
  Serial.print("hwserial ok");
  delay(500);
  softwareSerial.begin(9600);
  delay(3000);
  if (player.begin(softwareSerial)) 
  {
    Serial.println("OK");
    player.volume(20); //30 is very loud
  } 
  else 
  {
    Serial.println("Connecting to DFPlayer Mini failed!");
  }
}

void loop() 
{
  Serial.println("Playing #1");
  player.play(1);
  delay(8000);
  // over and over and over and. . .

My apologies - it's the Nano V3.1. Thanks!

By the way, the MP3 module I'm using is the 16-pin version (the first one listed in this following post) and is not a genuine DFRobot module.

https://forum.arduino.cc/t/df-player-warning/952842

OK.
If that player is supposed to work with the DFPlayer library then it should work with that sketch.

It's my understanding from that post that the MP3 module I think I'm using requires a custom library...I guess that's why I'm having such a hard time.

What "hard time"?
You posted a sketch with no library commands/instructions in it.

Maybe you could Upload the sketch that I posted.

So, I probably need to slow this down and explain the story of this MP3 journey...

I followed several tutorials and YouTube videos attempting to get this MP3 module to work. I breadboarded the circuits together to the exact specifications given and copied and pasted the example code given verbatim without any changes whatsoever, then compiled and uploaded the code to my Nano V3.1, but nothing...no sound - nothing.

As I was troubleshooting my circuit to ensure that I didn't have a miswiring or a damaged MP3 module, I accidentally shorted IO1 to ground momentarily while probing with my meter. As soon as I did that, the MP3 player started working and playing the files on the micro SD card. After reading the datasheet associated with the MP3 module and a little bit of experimentation, it became clear to me that the IO1 (or IO2) pins needed to be driven low momentarily to "enable" it work work. Once it started working, I was able to drive the IO1 (and IO2) pins low manually to get it change tracks, and alter the volume.

The issue I seem to be having is that I can't seem to write the sketch to do this, even though it should be a relatively easy thing to tell it to drive the "mp3DownPin" (or "mp2UpPin") LOW for a moment...it will only work if I do it manually on the breadboard.

Since the previous post I read seems to indicate that I'm using a "knockoff" of the genuine DFRobot MP3 player (i.e., the one that allegedly needs a custom library), I'm assuming that the "DFRobotDFPlayerMini.h" library will not work (according to the post I previously referenced).

So, this is where I am in this - I can make it do what I want when doing so manually, but I can't seem to get the Sketch to do it for me, and the "DFRobotDFPlayerMini.h" library doesn't seem to be doing anything in this sketch. I've invoked it, but I'm not convinced that it's actually doing anything.

Are you trying to tell me that you are unable to Copy & Paste my sketch and Upload it - or what?

No - our responses are crossing each other before we have a chance to read each other's replies...

Thank you for your sketch - I'll try it and report back what I find.

Thanks again for your help! I'll let you know!

So this code you provided works similarly to what I've described...it works, but only after I manually drive IO1 low momentarily by connecting this breadboard wire to ground for a moment.

I can manually connect IO1 (or IO2) to ground and control the volume this way and I can force it to change tracks by making and breaking the connection to ground quickly (simulating a fast button press).

I haven't run the sketch with the "IO" buttons connected, too.
I don't know how it would fudge it up that way though.
If that all is disconnected how do things go?
It's not the library.

I've disconnected IO1 and IO2 from the breadboard, so the only things connected are:

Vin (regulated 5V supply from a separate 12V to 5V regulator),
Ground (both pins 7 and 10)
Single 3W, 4-Ohm speaker connected to pins 6 and 8
RX pin on MP3 Module connected to Arduino Nano Pin 2 (via voltage divider at 3.3V)
TX pin on MP3 Module connected to Arduino Nano Pin 3 (straight connection)

No sound.

Do you have to take that IO1 momentarily low before every play or just once and it's good from there ?

VIN should be at least 7V.
Your regulated 5V should go to "5V" (instead).

Just once. After that one time, it's like it unlocks it or something. It works "normally," meaning it will play files, but I have to manually drive the IO1 and IO2 low to get it change tracks and change volume.

And about that VIN then --
your 5V external supply should go to "5V".

It does. Pin 1 (also depicted as Vcc on datasheet).

You just changed that from before?

No, there is only one voltage input on this module, and it's pin 1 that is called Vcc. There are no other input voltage pins on this module.

Is there not a terminal/pin labelled "5V"?