Robertsonics / Sparkfun mp3Trigger v2

We have 5 of these and have been using them in a few interactive installations – they do work. It might need a little bit of tinkering though:

– MicroSD card must be formatted to FAT 16 – the larger ones are FAT32 and it is not easy to format them on a mac. Some good instructions how to do that can be found here – at least the instructions how to do it using Terminal at the very bottom of the page worked.

– Large (8GB) MicroSD -cards might not work? SDHC cards at least don’t.

– Files max 192 (audio might be jumpy, better to try with 160 or 128?) mp3, iTunes conversion should be ok (not the best possible sound quality though)

– Files need to be named to TRACK001.mp3 …TRACK183.mp3 etc and be on the root of the SD card

Usage without Arduino: simple switches  to TRIG1 – TRIG 18, external power source and the power jumper to EXT, also the on-board navigation switch can be used – it is easier to test the board first without Arduino – does it find the SD Card, or the files (the Status led also blinks in various ways to tell if it succeeded or not, check datasheet for details).

Usage with Arduino: serial commands coming from Arduino Digital pin 1 (TX>) connected to the Mp3 trigger pin RX, power jumper to USB, Either with serial commands or with a library which can be downloaded here (not properly documented, the MP3Trigger.h -file contains the possible actions of the Library, not all of them are implemented yet). Mp3 Trigger Firmware communicates with Serial baud rate 38400 by default so you can see what it is fed from arduino.

Good instructions and setting up the files can be found here

Datasheet contains some essential information, Serial command codes, status light meanings etc.

The makerjam site actually designs the MP3 Trigger and has some info and more recent firmwares if you want to install them – they might help in higher bitrate playback, and there is an alternative firmware which allows for random play etc.

But here’s the code we got this s.o.b working with (only playing / stopping one track triggered by a value coming from an analog sensor  – Maxbotix ultrasonic proximity sensor in this case)

// Mp3 Trigger Firmware communicates with Serial baud rate 38400 by default

#include
MP3Trigger trigger;
boolean playing = false;
int triggerValue =100;

void setup() {
   pinMode(13, OUTPUT);
  //start serial communication with the trigger (over Serial)
  trigger.setup();
  trigger.setVolume(0); //loudest volume possible?
  //start looping TRACK001.MP3
  // trigger.setLooping(true,1);
  // trigger.setLooping(true,2);
}

void loop() {
  //necessary to receive signals from trigger
  trigger.update();

  int sensorValue = analogRead(A0);
  //  this line below is for checking sensor values,
  //  uncomment when finding out the correct value
    Serial.println(sensorValue, DEC);

     //  if sensor value is higher what we want, and the track is not playing
     //  (doublechecking really and to send the command only once)
     //  start playing, turn led off

        if (sensorValue > triggerValue && playing == false) {
         digitalWrite(13, LOW);   // set the LED off
              trigger.stop();   //stop whichever track is playing
          playing = true; // set playing to true so it won't start again
        }

     //  if sensor value is lower what we want, and the track is not playing
     //  (doublechecking really and to send the command only once)
     //  stop playing, turn led on

        if (sensorValue < triggerValue && playing == true) {
              digitalWrite(13, HIGH); // set the led on
              trigger.play(1);//play first track
             playing = false;

        }
// delay(20); // wait a little, probably not needed?
}

__________

update: Talking snowstatues, 2012 Design week.

Arduino software got updated, the code had to be changed a bit:

_____

#include <MP3Trigger.h>

MP3Trigger trigger;
boolean playing = false;
long randNumber;

void setup() {
   pinMode(13, OUTPUT);
  //start serial communication with the trigger (over Serial)
  // Start serial communication with the trigger (over SoftwareSerial)
  trigger.setup(&Serial);
  Serial.begin( MP3Trigger::serialRate() );
 // trigger.setVolume(0); //loudest volume possible?
//    Serial.begin(9600); 
  //start looping TRACK001.MP3
    randomSeed(analogRead(1));
   trigger.setLooping(true,1);
  // trigger.setLooping(true,2);
}

void loop() {
  //necessary to receive signals from trigger
//  trigger.update();
int triggerValue = 200;
  int sensorValue = analogRead(A0);
  //  this line below is for checking sensor values,
  //  uncomment when finding out the correct value
 //   Serial.print(playing);
  //  Serial.print("\t ");     
   // Serial.println(sensorValue, DEC);

     //  if sensor value is higher what we want, and the track is not playing
     //  (doublechecking really and to send the command only once)
     //  start playing, turn led off

        if (sensorValue > triggerValue && playing == false) {
         digitalWrite(13, LOW);   // set the LED off
          trigger.stop();   //stop whichever track is playing

          playing = true; // set playing to true so it won't start again
        }

     //  if sensor value is lower what we want, and the track is not playing
     //  (doublechecking really and to send the command only once)
     //  stop playing, turn led on

        if (sensorValue < triggerValue && playing == true) {
         randNumber = random(1,6); 
          trigger.trigger(randNumber);//play random

              digitalWrite(13, HIGH); // set the led on
             playing = false;

        }
 delay(20); // wait a little
}
----

Also: updated mp3Trigger Firmware. Cleaned out .DS_Store and other invisible files with command line. rm -rf /Volumues/tikku/.* Some of the mp3Triggers are broken? We got one set working, and it worked outside for a while. After powering off it didn’t start. Didn’t really check if there were any reasonable values coming from the sensor anymore. So I think our infrared sensors still suck when taken outdoors – a solution could be powering the box with 9V adapter, adding a 5V regulator and putting the thing inside a box…

In our Dama workshop, one student was using digital signal ultrasonic sensors, and they seemed to work outside, in minus 5-10 or so, so let’s keep on trying?