I recently received an MP3 Trigger (robertsonics version). I’ve been trying to get it to work with a serial connection from an Arduino MEGA2560 and I’m not sure if I’m doing something wrong in the sketch or I messed up when I soldered headers on to the board.
I’ve tested the board itself, everything works fine, I can play mp3’s and trigger them by jumping then on the board itself.
In terms of connection i’m power the MP3 Trigger externally (with the switch on EXT) and TX1-18 from the MEGA is going to RX on MP3 Trigger , as well as ground going between both.
This is the sketch that I’m using:
#include <PS3BT.h>
#include <SPI.h>
#include <SoftwareSerial.h>
#include <MP3Trigger.h>
MP3Trigger trigger;
#include <PS3BT.h>
USB Usb;
BTD Btd(&Usb);
PS3BT PS3(&Btd);
byte vol = 0; // 0 = full volume, 255 off
void setup() {
Serial.begin(115200);
trigger.setup(&Serial1);
trigger.setVolume(vol);
#if !defined(__MIPSEL__)
while (!Serial); // Wait for serial port to connect - used on Leonardo, Teensy and other boards with built-in USB CDC serial connection
#endif
if (Usb.Init() == -1) {
Serial.print(F("\r\nOSC did not start"));
while (1); //halt
}
Serial.print(F("\r\nPS3 Bluetooth Library Started"));
}
void loop() {
Usb.Task();
if (PS3.getButtonClick(SQUARE))
{
Serial.print(F("\r\nSquare"));
trigger.play(2);
}
}
Don’t know what library you’re using.
Have you tried any of the examples that come with that library?
The library is: MP3Trigger-for-Arduino-Master.
I’ve tried the examples but haven’t got any of them to work. The other libraries are for bluetooth control of a PS3 controller which is showing up on the serial monitor.
What pins on the Mega do you have the MP3 RX and TX connected to when you run the examples in the library?
Looks like the examples are sending data on pin 3 and receiving data on pin 2.
Keep in mind that pin 2 on the Mega isn’t capable of being used as RX, if the example is expecting data back from the MP3 board, it’s not going to work.
I’m using 18 and 19 on Mega which I thought was Serial1. This is my set up.
[
I tried “MP3TriggerBasic”
#include <MP3Trigger.h>
MP3Trigger trigger;
void setup() {
// Start serial communication with the trigger (over Serial)
trigger.setup(&Serial);
Serial.begin( MP3Trigger::serialRate() );
// Start looping TRACK001.MP3
trigger.setLooping(true,1);
}
void loop() {
// process signals from the trigger
trigger.update();
}
I also tried “BasicSoftSerialTrigger”
#include <SoftwareSerial.h>
#include <MP3Trigger.h>
SoftwareSerial trigSerial = SoftwareSerial(18, 19);
MP3Trigger trigger;
void setup() {
// Start serial communication with the trigger (over SoftwareSerial)
trigger.setup(&trigSerial);
trigSerial.begin( MP3Trigger::serialRate() );
// Start looping TRACK001.MP3
trigger.setLooping(true,1);
}
void loop() {
// process signals from the trigger
trigger.update();
}
For both it should start looping automatically right? I wasn’t sending any signals to the triggers. Also I deleted everything of the SD card and uploaded 1 mp3 named “TRACK001.mp3”](MP3-Trigger-bb hosted at ImgBB — ImgBB)
Hi makebreakshop.
There isn’t an ‘official’ Arduino library for the MP3 Trigger and I have seen a few different ones floating about the internet. I’m not sure which one you’re using, but I suspect it’s [this one.
I have not personally tried that library but I suspect the pins you’ve chosen to use are part of the issue. You’re trying to use software serial on a hardware serial port and RX won’t work with every pin on the Mega in software serial.
(see [here for a list of pins that do work)[/i][/size]
You might try moving to a different set of pins and see if that helps.
Try using this line in your code:
* *SoftwareSerial trigSerial = SoftwareSerial(10, 11); //Mega RX,TX* *
And connect the MP3 Triggers TX pin to pin 10 and the MP3 Triggers RX pin to pin 11. I haven’t tested this, but that might get things running for you.
SparkFun didn’t write this library and I don’t have any experience with it, but that might do the trick for you. If it’s not working, I’m not going to be able to help much more unfortunately.](https://www.arduino.cc/en/Reference/softwareSerial)](GitHub - sansumbrella/MP3Trigger-for-Arduino: A simple Arduino interface for the SparkFun MP3 Trigger. Put it in a folder called "MP3Trigger" inside your Arduino/libraries folder)