SparkFun Forums 

Where electronics enthusiasts find answers.

Your source for all things Atmel.
By eustace
#83165
I'm using an Arduino to control an Mp3 Trigger, but with limited success. Rather than hard triggering one of seven tracks, I am using the serial connection to trigger individual tracks (so I can play more tracks, of course). I can start a track using the T command, like this:
Code: Select all
void startTrack(int track)
{
  Serial.print('T', BYTE);
  Serial.print(track);
}
This command uses a byte, 'T', than an ascii value from 0 to 9, and it works great! I can start a track, no problem. But to access more tracks, I will need to use the 't' command, and send a byte value instead of an ascii value. And I'm afraid to go there. Because I've been trying to set the volume with the 'v' command, which also accepts a byte value, and every time I use it the volume goes completely away no matter what value is coming out the serial port. Here's my code:
Code: Select all
void setVolume(byte vol)
{
  Serial.print('v', BYTE);
  Serial.print(vol, BYTE);
  delay(500);
}
If I hook the Arduino up to the USB cable and set the speed to 38400 on the monitor, I can see my initial volume value coming over the serial connection, looking like vÿ. I can do this whether I am printing a byte that has been a byte value all along (initializing a byte variable from the top of the code) or whether I cast an int into a byte at some point along the way (like at the Serial.print point). But I can't get the board to do anything but turn the volume all the way down regardless of value. I would be pulling my hair out over this if I still had hair.

To keep things simple, I've been avoiding a two-way serial link between the mp3 trigger and my Arduino. Maybe I need to be reading it's output to debug this problem, but I thought I would post here first.
User avatar
By robertsonics
#83166
I'd suggest getting the 't' command working first, then you can be confident that you're sending the correct data values. For volume, any value over 64 (0x40 hex) will produce essentially silence.

There's a thread about using the 't' command with an Arduino at the MakerJam forum here - http://bit.ly/1VaO6p

Serial.write('t');
Serial.write(26);

This should start TRACK026.MP3, though it's probably not the most efficient way of coding it. Perhaps someone will chime in and explain how to combine into a single write statement.

Once that works...

Serial.write('v');
Serial.write(0);

...should produce full volume. Hope this helps.
By eustace
#83175
I read that volume command summary at least twice without the range of values actually sinking in. D'oh! Now I've got ascii & binary track triggering and volume control - everything my project needs. Thanks, and thanks for the link, too.
By jordansears
#136810
hey man, i'm having the same problems. would you mind posting your code for this project? i need it to help with my thesis proj!!!

thanks
jordan