Code help with vs1053 mp3 shield

Hello to all... I have a geeetech vs1053 mp3 shield on a mega that is using capacitive sensors to trigger mp3 files. Everything is fine except the files only play whilst touching the sensor. As soon you disengage from the sensor the file stops playing.

What I would like to do is have the file play through to it's end uninterrupted once it has been triggered and then stop. Could anyone advise me how i could modify the code to accommodate this?

#include <SPI.h>
#include <SdFat.h>
#include <SFEMP3Shield.h>
#include <CapacitiveSensor.h>

SdFat sd;
SFEMP3Shield MP3player;

CapacitiveSensor   cs_5_33 = CapacitiveSensor(5, 33);       // 10M resistor between pins 4 & 2, pin 2 is sensor pin, add a wire and or foil if desired
CapacitiveSensor   cs_5_34 = CapacitiveSensor(5, 34);
CapacitiveSensor   cs_5_35 = CapacitiveSensor(5, 35);



void setup()
{
  cs_5_33.set_CS_AutocaL_Millis(0xFFFFFFFF);     // turn off autocalibrate on channel 1 - just as an example
  Serial.begin(9600);


  sd.begin(SD_SEL, SPI_HALF_SPEED);
  MP3player.begin();

}

void loop()
{

  long start = millis();
  long total1 =  cs_5_33.capacitiveSensor(30);
  long total2 =  cs_5_34.capacitiveSensor(30);
  long total3 =  cs_5_35.capacitiveSensor(30);

  Serial.print(total1);
  Serial.print("--");
  Serial.print(total2);
  Serial.print("--");
  Serial.println(total3);
  delay(10);

  if (total1 > 40)
  {
    MP3player.playTrack(1);
  }
  else  if (total2 > 40)
  {
    MP3player.playTrack(2);
  }
  else  if (total3 > 40)
  {
    MP3player.playTrack(3);
  }
  else
  {
    MP3player.stopTrack();
  }
 

}

Could anyone advise me how i could modify the code to accommodate this?

Dirt simple. Stop calling MP3player.stopTrack().

Not sure why you do this:

long start = millis();

Since you never use the 'start' variable that you created.

BUT, if you do want to work with millis(), then all variables involved should be unsigned long.

"Dirt simple. Stop calling MP3player.stopTrack()." Perfect!!!

"long start = millis();" Left from previous mods flying around...

Thanks for your help!!

For anyone who needs this code functioning as described here it is...

#include <SPI.h>
#include <SdFat.h>
#include <SFEMP3Shield.h>
#include <CapacitiveSensor.h>

SdFat sd;
SFEMP3Shield MP3player;

CapacitiveSensor   cs_5_33 = CapacitiveSensor(5, 33);       // 10M resistor between pins 5 & 33, pin 5 is sensor pin, add a wire and or foil if desired
CapacitiveSensor   cs_5_34 = CapacitiveSensor(5, 34);
CapacitiveSensor   cs_5_35 = CapacitiveSensor(5, 35);


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

  sd.begin(SD_SEL, SPI_HALF_SPEED);
  MP3player.begin();
  MP3player.setVolume(0, 0);                 // set volume of the mp3 player ( 0 = loudest )

}

void loop()
{

  long total1 =  cs_5_33.capacitiveSensor(30);
  long total2 =  cs_5_34.capacitiveSensor(30);
  long total3 =  cs_5_35.capacitiveSensor(30);

  Serial.print(total1);
  Serial.print("--");
  Serial.print(total2);
  Serial.print("--");
  Serial.println(total3);

  if (total1 > 40)
  {
    MP3player.playTrack(6);

  }
  else  if (total2 > 40)
  {
    MP3player.playTrack(7);

  }
  else  if (total3 > 40)
  {
    MP3player.playTrack(8);

  }
}