SoftwareSerial for an mp3 player

Hi, im currently having trouble with software serial, as i want to read what is being transmitted and recieved from a player module im currently trying to set up. The board i am using is an arduino UNO v3, The code im using is:

#include <SoftwareSerial.h>

#define rxPin 7
#define txPin 8

// set up a new serial port
SoftwareSerial mySerial =  SoftwareSerial(rxPin, txPin);
byte pinState = 0;

void setup()  {
  // define pin modes for tx, rx, led pins:
  pinMode(rxPin, INPUT);
  pinMode(txPin, OUTPUT);
  // set the data rate for the SoftwareSerial port
  Serial.begin(19200);
  Serial.println("Test of arduino player module");
  
  mySerial.begin(19200);
  mySerial.println("\\:n");
}
void loop

The problem is that for the software serial "mySerial" im and not getting any information show up in the serial monitor. I have the player module connected to pins 7 and 8, but not even transmitted ":n" is showing up in the serial monitor, only the "Test for arduino player module"

My final goal is to be able to have my player module, play songs off it's SD card by a filename. I am trying to see what i recieve from the play module with software serial, hoping for atleast a "file not found" so i no im on the right track.

Link to player module commands if needed: DFRduino_Player_module_.NET_Gadgeteer_Compatible___SKU_TOY0008_-DFRobot the link includes that las ")" some reason it dosent link

The problem is that for the software serial "mySerial" im and not getting any information show up in the serial monitor.

First, you don't have a mySerial attached to the Arduino, using pins 7 and 8, do you? If you used a meaningful name for the SoftwareSerial instance, it just MIGHT become obvious what the problem is.

SoftwareSerial mp3player = SoftwareSerial(rxPin, txPin);

Now, when you do mp3player.print(), mp3player.write(), mp3player.available(), and mp3player.read(), it is quite obvious what you are writing to/reading from.

Second, the data that goes back and forth between the Arduino and the mp3 player is NOT going to appear on the Serial Monitor. You need to make that happen by reading from the mp3 player, using mp3player.read() and writing to the Serial Monitor using Serial.print().

Third, snippets are for http://snippets-r-us.com. Here, we, quite reasonably, expect to see ALL of your code.

So, iv solved my problem, i can now play a filename through a serial.println.

All i want to do now is read the player module so it will tell be, when the song ends, when it starts, things like "file not found" etc. The module is capable of;

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 code:

int incomingByte = 0;
void setup()  {
  // define pin modes for tx, rx, led pins:
  pinMode(0, INPUT);
  pinMode(1, OUTPUT);
  digitalWrite(0, HIGH);
  digitalWrite(1, HIGH);
  // set the data rate for the SoftwareSerial port
  Serial.begin(19200);
  Serial.println("Test of arduino player module");
  delay(2000);
  Serial.println("\\:v 210\r\n");
  delay(2000);
  Serial.println("\\7\r\n");
}
void loop () {
          // send data only when you receive data:
        if (Serial.available() > 0) {
                // read the incoming byte:
                incomingByte = Serial.read();

                // say what you got:
                Serial.print("I received: ");
                Serial.println(incomingByte);
        }
}

Problem is, this serial read, prints it in decimals and i want this in the text eg. File not found, Play ok.. im new to arduino programming so not familiar with Serial.read

All i want to do now is read the player module so it will tell be, when the song ends, when it starts, things like "file not found" etc.

Where are you going to display the data?

You seem to have the mp3 player on the hardware serial port, which means that you won't be able to use the hardware serial port to talk to the PC.

Connect to your mp3 player using SoftwareSerial. Send commands to it using those pins. Read the input back from those pins and send it to the screen using Serial.print.

dannable:
Connect to your mp3 player using SoftwareSerial. Send commands to it using those pins. Read the input back from those pins and send it to the screen using Serial.print.

ok i understand how to send commands to the pins. Im just guessing how to read the input back from the pins.. within the software serial.. but no idea on using serial.print. this is what i got:

#include <SoftwareSerial.h>

SoftwareSerial mp3player(7,8); //RX, TX

void setup()  {
  // define pin modes for tx, rx, led pins:
  pinMode(0, INPUT);
  pinMode(1, OUTPUT);
  digitalWrite(0, HIGH);
  digitalWrite(1, HIGH);
  // set the data rate for the SoftwareSerial port
  Serial.begin(19200);
  Serial.println("Test of arduino player module");
  delay(2000);
  mp3player.begin(19200);
  mp3player.println("\\:v 210\r\n");
  mp3player.read();
  mp3player.print(); // ????
  
}
void loop()
{
}

Look up Serial.print and Serial.println for an explanation and guidance on how to use them. Once you have the hardware serial port working add your mp3 player using SoftwareSerial. You had that working earlier as you could use the 'next track' command. Once both work in the same program read data from the SoftwareSerial port and write it to the Serial port.

#include <SoftwareSerial.h>
int test = 0;
SoftwareSerial mp3player = SoftwareSerial(7,8); //RX, TX

void setup()  {
  // define pin modes for tx, rx, led pins:
  pinMode(0, INPUT);
  pinMode(1, OUTPUT);
  digitalWrite(0, HIGH);
  digitalWrite(1, HIGH);
  // set the data rate for the SoftwareSerial port
  Serial.begin(19200);
  mp3player.begin(19200);
  mp3player.println("\\:v 210\r\n");
  mp3player.println("\\5\r\n");
  test = mp3player.read();
  mp3player.print("i got: ");
  mp3player.println(test);
}
void loop()
{
}

this plays the song "5" but... the serial monitor is blank?

Seeing as you are printing it to mp3player.print rather than serial.print what do you expect? Have you got a simple Serial.print to work?

ok starting to understand

got this so far:

#include <SoftwareSerial.h>

SoftwareSerial mp3player = SoftwareSerial(7,8); //RX, TX

void setup()  {
  // define pin modes for tx, rx, led pins:
  pinMode(0, INPUT);
  pinMode(1, OUTPUT);
  digitalWrite(0, HIGH);
  digitalWrite(1, HIGH);
  // set the data rate for the SoftwareSerial port
  Serial.begin(19200);
  mp3player.begin(19200);
  mp3player.println("\\:v 210\r\n");
  Serial.print("i got: ");
  Serial.println(mp3player.read());
  mp3player.println("\\5\r\n");
  Serial.print("i got: ");
  Serial.println(mp3player.read());
}
void loop()
{
}

serial monitor give me numbers though, whats next ?

serial monitor give me numbers though, whats next ?

You tell us what the numbers ARE.

  Serial.println(mp3player.read());

The read() method returns an int. The print method converts the int to a string. That is NOT what you want. You need to do one of these:

char ltr = mp3player.read();
Serial.println(ltr);

or

  Serial.println((char)mp3player.read());

There is a available() method that tells you how many (could be 0) characters there are to read. It would then be necessary for you to loop and read all the data.

serial monitor give me numbers though

Print the ASCII characters the numbers represent.

PaulS:

char ltr = mp3player.read();

Serial.println(ltr);

Using that method, in the serial monitor i get,

i got: ÿ
i got: ÿ
on 19200 braud and "both NL & CR"

Using:

Serial.begin(19200);
  mp3player.begin(19200);
  mp3player.println("\\:v 210\r\n");
  Serial.print("i got: ");
  Serial.println((char)mp3player.read());
  delay(1000);
  mp3player.println("\\5\r\n");
  Serial.print("i got: ");
  Serial.println((char)mp3player.read());[\code]

i got: o
i got: l

The y with the two dots above it is what you get when the letter is -1. That is what read() returns when there is no data to read (yet).

Move the code to read and print into loop. Serial data takes a while to move.

Have a look at this page, and the examples shown:

And don't try to run before you can walk!

PaulS:
The y with the two dots above it is what you get when the letter is -1. That is what read() returns when there is no data to read (yet).

Move the code to read and print into loop. Serial data takes a while to move.

#include <SoftwareSerial.h>

SoftwareSerial mp3player = SoftwareSerial(7,8); //RX, TX

void setup()  {
  // define pin modes for tx, rx, led pins:
  pinMode(7, INPUT);
  pinMode(8, OUTPUT);
  digitalWrite(7, HIGH);
  digitalWrite(8, HIGH);
  // set the data rate for the SoftwareSerial port
  Serial.begin(19200);
  mp3player.begin(19200);
}
void loop()
{
  mp3player.println("\\:v 210\r\n");
  delay(50);
  while (mp3player.available() >0) {
    char ltr = mp3player.read();
    Serial.print("i got: ");
    Serial.println(ltr);
    delay(1000);
  }
}

with this the serial loops:

got: k
i got:

i got:

i got: o
i got: l
i got: s
i got: e
i got: t
i got:
i got: o
i got: k
i got:

i got:

i got: v
i got: l
i got:

i no it should say "vol set ok" but its a bit off atm? and also is there a way to get it presented in one line?