school project - Arduino player module

Hey,

I recently purchased an Arduino UNO rev3 along with a player module from DFrobot. I also have other bits and pieces like sensors and buttons for the school project im working on. I understand the basics of programming, however i am not quite sure what to do about using my player module.

Currently i have programmed my board to play the next track on the SD in the player module when u press a button. What i want to do however, is call a filename on the SD and play it.

The player module from DF robots comes with the following commands:

Support Commands

Play music via receiving filename command "filename\r\n" Return "Play ok\r\n" if success. Return "Not found\r\n" if failed to find the file.
Return "over\r\n" if finish playing one song.
Pause Play ":p\r\n" Return "pause\r\n" if success
Continoue Play ":s\r\n" Return "start\r\n" if success
Play next ":n\r\n" Return "next\r\n" if success?Return "false\r\n" if failed
Play previous ":u\r\n" Return "key up\r\n"
Set the volume ":v 255\r\n"?set the volume, from 0 (minimum)-255 (maximum), Return "vol set ok" if success

My current program is:

// Product name: DFRduino Player Module
// # Product SKU :TOY0008
// # Version : 0.1

// # Description:
// # This sample code is for testing DFRduino Player Module

// # Connection:
// # Arduino MP3
// # TX RX
// # RX TX
// # 5V +5V
// # GND GND

// # Support Commands:
// # 1. Pause Play ":p\r\n" Return "pause\r\n" if success
// # 2. Continoue Play ":s\r\n" Return "start\r\n" if success
// # 3. Play next ":n\r\n" Return "next\r\n" if success?Return "false\r\n" if failed
// # 4. Play previous ":u\r\n" Return "key up\r\n"
// # 5. Set the volume ":v 255\r\n"?set the volume, from 0 (minimum)-255 (maximum), Return "vol set ok" if success

int button = 6;//button in digital 3

void setup()
{
pinMode(button, INPUT);
Serial.begin(19200);
delay(2000);//Wait for 2 seconds
Serial.println("\:v 225"); // set the volume, from 0 (minimum)-255 (maximum)
delay(50);
}

void loop()
{

if(digitalRead(button)==LOW)
{
delay(50);
if(digitalRead(button)==LOW)
{

Serial.println("\:n"); // Play next
Serial.println("OK");

}
}
}

So what i want to know is how i go about calling a filename?

First, don't post the same question in different parts of the forum.
This is called cross-posting because it makes people very CROSS. But don't worry, I've deleted your other post.

Then, read the sticky thread at the top of this (and every other) section of the forum.

So what i want to know is how i go about calling a filename?

Is this one of those "Alice's Adventures in Wonderland" "what is the name of the song called?" type questions?
(To which the answer is, I think, "Haddock's Eyes")

Edit: Apologies; it is from "Through the Looking Glass".

im not quite sure i understood your reference there. i have pre-loaded songs onto a SD card, simply named "trk, trk1, trk2" etc.. and i want to be able to use the filename to play the song i want.

im not quite sure i understood your reference there

Depending on your interpretation, it's a discourse on either meta-names or use-mention distinction.

agwhiteb0i:
im not quite sure i understood your reference there. i have pre-loaded songs onto a SD card, simply named "trk, trk1, trk2" etc.. and i want to be able to use the filename to play the song i want.

Well, to start with, see if you can get the device to play a specific track, say trk3 from setup to see if the syntax in your comments is correct.

im not sure how this is helping my current issue.... uhh.

So what i want to know is how i go about calling a filename?

It isn't clear to me what you mean by "calling" in this context.
The usual way to represent a filename in a programming context would be as a C string, but what you call the string is completely up to you: char* haddocks_eyes = "trk1.wav";

by call i mean, i want to be able to, using my player module, PLAY any song by it's respectable filename. the PROBLEM is, i do not know how to do this, or if it can be done with my player module.

My player modules uses:

Serial.println("\:n"); // Play next
Serial.println("OK");

to initate its commands, however for example, instead of "Playing the next song in the folder" i want to have a filename it searches for in the folder and plays.

From your original post:

Play music via receiving filename command "filename\r\n" Return "Play ok\r\n" if success. Return "Not found\r\n" if failed to find the file.

Does that work?

im not sure, it might, but how do i set it out? i tried Serial.println("trk"); but it didnt work soo...

i tried Serial.println("trk");

Does the filename require the extension too?

well, i have also tried Serial.println("trk.mp3");
and also the following:
Serial.println("trk\r\n"); and the same with extension
Serial.println("\:trk.mp3"); and the same without extension
Serial.println(":trk.mp3"); and the same without extension
Serial.println("\trk.mp3"); and the same without extension

Does your original sketch play anything?

yes my current sketch plays the next track in the directory on the SD, in order from top to bottom, because of the
Serial.println("\:n"); \play next

Assuming your button is pulled up high so it won't interfere, what does this do, called as the last line in setup:

Serial.println("trk.mp3");

The nest step, then, is for you to post a link to the device and library you are using.

doing what you said wildbill, this is what i have:

int button = 6;//button in digital 3

void setup()
{
pinMode(button, INPUT);
Serial.begin(19200);
delay(2000);//Wait for 2 seconds
Serial.println("\:v 225"); // set the volume, from 0 (minimum)-255 (maximum)
delay(50);
Serial.println("trk.mp3");
}

void loop()
{

if(digitalRead(button)==LOW)
{
delay(50);
if(digitalRead(button)==LOW)
{
Serial.println("\:n"); // Play next
}
}
}

should i turn button to high so they dont do anything? i did that and had nothing play, and leaving the buttons how they are, it just does its normal, playing through songs from top to bottom

Just delete (or comment out) everything in loop for now.

Put your SD card in something else that can read it and see what's actually on it, including file extensions.

You might try switching to software serial so you can read the device's serial port and echo it to the IDE terminal to see if the device has anything interesting to say - likely just file not found, but you never know.

EDIT:

int button = 6;//button in digital 3

void setup()
{
pinMode(button, INPUT);
Serial.begin(19200);
delay(2000);//Wait for 2 seconds
Serial.println("\:v 225"); // set the volume, from 0 (minimum)-255 (maximum)
delay(50);
Serial.println("trk.mp3");
Serial.println("\:s");
}

void loop()
{
}

it required the Serial.println("\:s"); to start the playback.

however if i change the track to say trk2.mp3 (on the SD) it still plays trk.mp3

EDIT:

In serial monitor, it sais "trk.mp3" however nothing like file not found or play ok success

You're not using the built-in pullup resistors - can we assume you've got some connected externally?

(Please use code tags when posting code)