Problem combining CapSense values with MP3 Player Shield playTrack

Hello,

I’m trying to combine CapSense values with audio tracks using the MP3 Player Shield by sparkfun, using the library from Bill Porter (SFEMP3Shield).

Basically I want my shield to play a certain track when one of the sensors go above a threshold.

My sensors all work well and my serial monitor can write its values using long integers but when I try to simultaneously play an audio track it goes wrong. I want that “if sensor1 goes above 1500, playTrack (1)”. I can play a track and I can measure the sensors but not at the same time. Any idea how to combine this or why currently it’s not working?

My code:

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

SdFat sd;
SFEMP3Shield MP3player;

CapacitiveSensor   cs_5_10 = CapacitiveSensor(5,10);        // 10M resistor between pins 4 & 2, pin 2 is sensor pin, add a wire and or foil if desired
CapacitiveSensor   cs_5_11 = CapacitiveSensor(5,11);
CapacitiveSensor   cs_5_13 = CapacitiveSensor(5,13);




void setup()                    
{
   cs_5_10.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_10.capacitiveSensor(30);
    long total2 =  cs_5_11.capacitiveSensor(30);
    long total3 =  cs_5_13.capacitiveSensor(30);
   
    

    
   Serial.print(total1);
   Serial.print("--");
   Serial.print(total2);
   Serial.print("--");
   Serial.println(total3);                
   delay(10);                             
     
    if (total1 > 1500)
    {
      MP3player.playTrack(1);
    }
    else
    {
      MP3player.stopTrack(); 
    }
  

  
  
}

As soon as the value “total1” goes above 1500 (threshold), the monitor stops counting and nothing happens regarding audio. My guess is that MP3player.playTrack() stops it, also stopping the audio instantaneously.
I hope someone can help me out, I’m not the best at programming Arduino so take it easy on me ;).

Regards,

Falx

A link to the shield you are using would be useful. How does the Arduino communicate with the mp3 player?

CapacitiveSensor   cs_5_10 = CapacitiveSensor(5,10);        // 10M resistor between pins 4 & 2, pin 2 is sensor pin, add a wire and or foil if desired

If the comment doesn't match the code, fix it!

PROBLEM SOLVED!

Realized later that the ports 10 11 and 13 are the SPI ports which the MP3 player shield needs.
Put the sensors on the analog pins and everything works now!