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();
}
}