PIR triggers sound, but no sound heard

Like so many of you have heard a million times here, I can confess to being one of the "totally newbie to Arduino and no C programming skills"... :o

So thanks to Ctrl+C and some imagination I have come up with code that I was hoping to use as a PIR triggering on motion and then playing a MP3 file from an sd card. When a sound is played Another sound shouldn't be triggered for 60 seconds.

I have the Sparkfun MP3 Shield and a Parallax PIR. I have tried to use the examples I have been pointed to.

The serial monitor just says "calibrating sensor", then "ready", and then "Trigger Ready" every time the PIR has been triggered and the delay has passed, but no sound plays!

The sound file on the FAT32 formatted card is called track001.mp3.

Can someone help me find the problem?

Thanks a million!

   MP3 Shield Trigger 
   by: Jim Lindblom 
       SparkFun Electronics 
   date: September 23, 2013 

#include <SFEMP3ShieldConfig.h> 
#include <SFEMP3Shieldmainpage.h> 
#include <SPI.h>           // SPI library 
#include <SdFat.h>         // SDFat Library 
#include <SdFatUtil.h>     // SDFat Util Library 
#include <SFEMP3Shield.h>  // Mp3 Shield Library 

int pirPin = 10;    //the digital pin connected to the PIR sensor's output 
int calibrationTime = 15;  

SdFat sd; // Create object to handle SD functions 

SFEMP3Shield MP3player; // Create Mp3 library object 
// These variables are used in the MP3 initialization to set up 
// some stereo options: 
const uint8_t volume = 0; // MP3 Player volume 0=max, 255=lowest (off) 
const uint16_t monoMode = 1;  // Mono setting 0=off, 3=max 
    //create a string with the filename

void setup() 
   initSD();  // Initialize the SD card 
   initMP3Player(); // Initialize the MP3 Shield 
  pinMode(pirPin, INPUT); 

  //give the sensor some time to calibrate 
  Serial.print("calibrating sensor "); 
    for(int i = 0; i < calibrationTime; i++){ 
    Serial.println(" done"); 
    Serial.println("SENSOR ACTIVE"); 

void loop() 
     if(digitalRead(pirPin) == HIGH){ 
       /* If another track is playing, stop it: */ 
       if (MP3player.isPlaying()) 
       /* Use the playMP3 function to play a numbered track: */ 
         uint8_t result = MP3player.playMP3("track001.mp3"); 
         Serial.println("Trigger Ready! ");      //output 
/* initSD() initializes the SD card and checks for an error. */
void initSD() 
   //Initialize the SdCard. 
   if(!sd.begin(SD_SEL, SPI_HALF_SPEED)) 

/* initMP3Player() sets up all of the initialization for the */
/* MP3 Player Shield. It runs the begin() function, checks */
/* for errors, applies a patch if found, and sets the volume */ 
/* stereo mode. */
void initMP3Player() 
   uint8_t result = MP3player.begin(); // init the mp3 player shield 
   if(result != 0) // check result, see readme for error codes. 
     // Error checking can go here! 
   MP3player.setVolume(volume, volume); 

Initially I also wanted a 433 MHz transmitter to send a RF code to a remote controlled electrical socket to Power up a lamp at the same time the sound goes off, but it seems too much for me? I couldn't even get a read out of the remote codes even if I use a standard example sketch on sniffing codes. No idea how the transmitting code would be. Any tips also for this?

Have you ever been able to play a track using the MP3 shield alone ?

Have you ever been able to play a track using the MP3 shield alone ?

In an earlier version of my code the mp3 played when it initialized, so I guess the shield and sd card are ok?

Try playing an MP3 from setup() to ensure that the hardware is working. Turn on the onboard LED when the PIR is triggered so that you know exactly when it happens. Do you really need to stop a previous track playing ? Is playMP3() a blocking function or does it return immediatley to the program that called it and play the MP3 in the background ? I am suspicious of the use of the delay() function in this context. What happens if you remove it ? Consider changing the code to detect when the PIR becomes triggered rather than when it is triggered.

You are correct! When I connected the board today it began playing all tracks on the sd card. But not when I tried calling playMP3 in setup. I removed delay with no effect. I get a bit random results which made me check all soldering if I had a cold one. I have to run a test again with an unmodified example for the sparkfun mp3 shield to check the hardware.

I'll be back! :slight_smile: