Pages: 1 ... 10 11 [12]   Go Down
Author Topic: * MP3 Shield * - Rogue Robotics rMP3  (Read 39022 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
Newbie
*
Karma: 0
Posts: 19
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hooray,

I finally have got it compiled using version 11 of the new software serial. I exported it to my arduino, but cant hear anything. Not sure why, I have the name of the song correct, and its location on the SD card. I think It may be a connection issue between the uno board and the rmp3
Logged

Toronto, ON
Offline Offline
Full Member
***
Karma: 10
Posts: 233
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

heh... I just posted some info above.  Glad you got it working!

Can you post the code you're using, or is it one of the examples?

b
Logged


0
Offline Offline
Newbie
*
Karma: 0
Posts: 19
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I am just using this:
Code:
#include <SoftwareSerial.h>

#include <RogueMP3.h>
 
SoftwareSerial rmp3_serial(6, 7);
RogueMP3 rmp3(rmp3_serial);
 
void setup()
{
  Serial.begin(9600);
  rmp3_serial.begin(9600);
 
  rmp3.sync();
 
  rmp3.playfile("/gold.mp3");
}
 
void loop()
{
}

Which seems to be on the rmp3 now, just nothing coming out of the headphones. I still have it plugged into my laptop for power just now.

The serial leds on the uno don't seem to be flashing either. I assume that with that code, the mp3 should just play on loop?

I have the mp3 called gold.mp3 on the root and in a subfoler called /mp3/gold.mp3 on the card. I renamed the file to gold.mp3, so i guess it is called gold.mp3.mp3, and tried it without the extra extension, and still no joy?
Logged

Toronto, ON
Offline Offline
Full Member
***
Karma: 10
Posts: 233
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Try this code, and start the Serial Monitor after you upload:

Code:
#include <SoftwareSerial.h>

#include <RogueMP3.h>

SoftwareSerial rmp3_serial(6, 7);
RogueMP3 rmp3(rmp3_serial);

void setup()
{
  Serial.begin(9600);
  rmp3_serial.begin(9600);

  Serial.println("Starting rMP3");

  rmp3.sync();

  Serial.println("rMP3 Ready");

  rmp3.playfile("/gold.mp3");

  Serial.println("File playing");
}

void loop()
{
}


Let me know what you see in the Serial Monitor.

b
Logged


0
Offline Offline
Newbie
*
Karma: 0
Posts: 19
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

It just hangs at starting mp3. I am correct in having all the pins from the uno jumped to the rmp3? Doing this wont interfere with the two boards talking?

Thank you
Logged

Toronto, ON
Offline Offline
Full Member
***
Karma: 10
Posts: 233
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Does your rMP3 setup look like this:



or do you have an rMP3 without pins?

b
Logged


0
Offline Offline
Newbie
*
Karma: 0
Posts: 19
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Very similar. I couldn't get mine with the pins, so I have used my own. But I think I have got the same set up with them


With the usb from the uno going to my laptop.
Logged

Toronto, ON
Offline Offline
Full Member
***
Karma: 10
Posts: 233
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Try this sketch, and tell me what you see in the Serial Monitor:

Code:
// Autobaud detect for rMP3/uMP3/uMMC
// Copyright 2011 Brett Hagman
// Rogue Robotics
// http://www.roguerobotics.com/

#include <SoftwareSerial.h>

SoftwareSerial rmp3_serial(6, 7);


int16_t read_timeout(uint32_t timeout)
{
  uint32_t start = millis();

  while ((millis() - start) < timeout)
  {
    if (rmp3_serial.available())
      return (uint8_t) rmp3_serial.read();
  }

  return -1;
}


boolean testbps(uint32_t bps)
{
  rmp3_serial.begin(bps);
  rmp3_serial.write(0x1b);  // send ESC
  if (read_timeout(100) == '>')
    return true;
  else
    return false;
}


void setup(void)
{
  uint32_t bps[] = { 2400, 4800, 9600, 19200, 38400, 57600, 115200 };
  uint8_t i;

  Serial.begin(9600);

  Serial.println("Started");

  for (i = 0; i < sizeof(bps)/sizeof(uint32_t); i++)
  {
    Serial.print("Trying: ");
    Serial.print(bps[i], DEC);
    if (testbps(bps[i]))
    {
      Serial.println(" YES!");
      break;
    }
    else
    {
      Serial.println(" No");
    }
  }

  // now set new bps
  
  // rmp3_serial.print("ST D 4\r");
}

void loop(void)
{
}

b
Logged


0
Offline Offline
Newbie
*
Karma: 0
Posts: 19
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Returns "no" for all of them 2400-115200
« Last Edit: January 18, 2011, 09:21:29 pm by jennyc » Logged

Toronto, ON
Offline Offline
Full Member
***
Karma: 10
Posts: 233
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Double check pins 6 and 7 at the rMP3 - make sure they are soldered well.  Resolder them, if need be, and try again.

b
Logged


0
Offline Offline
Newbie
*
Karma: 0
Posts: 19
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Is it just those to pins that need to be soldered down? Or am I ok to have all of them soldered to the same pin on the uno board?

I don't have access to my soldering iron at the moment, will be back with it tomorrow. I will double check 6&7 ?and the rest? of the pins, and will let you know how it works from there.

Thank you for your help

Jenny
Logged

Toronto, ON
Offline Offline
Full Member
***
Karma: 10
Posts: 233
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

No problem!

Yeah, just need to make sure 5V, Ground (GND), and pins 6 and 7 are well soldered.  Those are the only pins that are used.  If you have the pins soldered, it's just as good - just more work. smiley

b
Logged


0
Offline Offline
Newbie
*
Karma: 0
Posts: 19
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Turns out that was the problem.

Its working now. =D Thank you very much.

Away off to read about using the getspectrumanalyser() to get the rmp3 giving the arduino a value, so that an output can be created depending on the value. That sound about right?

Thanks again
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 19
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi

edit::

Sorry, I have just looked back and seen that I pasted the wrong code, I just pasted yours, oops.

I was using your code as a base for mine.

I think I have got to a point where it should be analysing the code, but I am not sure as to what each part of your original code actually does. I have tried to edit it with the code to play from the folder /mp3/ and the audio is not playing, but have had a version where it did only play my song gold.mp3.

From what I can tell from your code, mine should now be analysing for 3 different bands, and sending it back to the arduino. My problem is now, I am not sure how to change this from the lcd output, to just have a different arduino output turned "on" when each frequency returned.
Code:
#include <SoftwareSerial.h>
#include <RogueMP3.h>
#include <RogueSD.h>

SoftwareSerial rmp3_s(6, 7);
 
RogueMP3 rmp3(rmp3_s);
RogueSD filecommands(rmp3_s);
 
uint16_t bandfreqs[] = {  120,  2000,  20000 };
 
uint16_t numfiles = 0;
 
#define MP3PATH "/mp3/"
// you need to put the two double quotes ("") in the middle below,
// because the Arduino IDE looks for unclosed comments.
#define MP3FILTER "/mp3/""*.mp3"


void doFREQSpec(void)
{
  // prepare for up to 3 bands
  uint8_t v[3];
 
  rmp3.getspectrumanalyzer(v);
 
}

void setup(void)
{
  Serial.begin(9600);
  Serial.println("Started");
  Serial.println("Starting sync");
  rmp3.sync();
  filecommands.sync();
  Serial.println("Done sync");
  
}


void playTrack(void)
{
  char mp3path[128];
 
// ...
 
  rmp3.playfile(mp3path);
 
  rmp3.setspectrumanalyzer(bandfreqs, 10);
 
  Serial.println("Playing");
}

void loop(void)
{
  
}

Currently my code is stuck on the syncing. I will keep trying to get this working with the folder, but as a failsafe, I have it working with a single track.

Is there a specific part of the documentation that I can read, or a direction you can point me in on how to translate this back to an arduino output?

Thanks

Jenny
« Last Edit: January 21, 2011, 06:12:21 pm by jennyc » Logged

Toronto, ON
Offline Offline
Full Member
***
Karma: 10
Posts: 233
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

@jennyc:  Here is an example I wrote.  In my case, I am using a LEDHead with LEDs to display output.

Code:
#include <RogueMP3.h>
#include <NewSoftSerial.h>

NewSoftSerial rmp3_s(6, 7);

RogueMP3 rmp3(rmp3_s);

#define numberOfBands 3
uint16_t bandfreqs[] = { 120, 2000, 20000 };
//uint8_t outputPin[] = { 2, 3, 4 };
uint8_t outputPin[] = { 29, 30, 31 };

#define THRESHOLD 12

#define songname "/001.mp3"


void checkFrequencies(void)
{
  // prepare for up to 23 bands
  uint8_t v[23];

  rmp3.getspectrumanalyzer(v);

  for (uint8_t i=0; i<numberOfBands; i++)
  {
    if (v[i] > THRESHOLD)
      digitalWrite(outputPin[i], HIGH);
    else
      digitalWrite(outputPin[i], LOW);
  }
}


void setup(void)
{
  Serial.begin(9600);
  Serial.println("Started");

  rmp3_s.begin(9600);

  for (uint8_t i = 0; i < numberOfBands; i++)
    pinMode(outputPin[i], OUTPUT);

  Serial.println("Starting sync");
  rmp3.sync();
  Serial.println("Done sync");
}


void playTrack(void)
{
  Serial.println("Playing Track");
 
  rmp3.playfile(songname);

  rmp3.setspectrumanalyzer(bandfreqs, numberOfBands);
}

int8_t isPlaying(void)
{
  return (rmp3.getplaybackstatus() == 'P' ? 1 : 0);
}


void loop(void)
{
  if (!isPlaying())
    playTrack();

  checkFrequencies();
}

You'll definitely have to have different thresholds for each band, since they will have different responses.

b
Logged


Pages: 1 ... 10 11 [12]   Go Up
Jump to: