- Sun Feb 15, 2015 6:39 pm
#179749
Hello SparkFun Forum,
Working on getting a PIR sensor to fire an MP3 player.
I tried the code at
https://learn.sparkfun.com/tutorials/mp ... eld-hookup
This will play track 1 when pin 0 is shorted to ground
but shorting pin 0 again does nothing. One can short pin 0
get the track to play then short pin 2 and get results
and then short pin 1 and get results but shorting pin 1
repeatedly only provides results the first time.
So I wrote code but the code I wrote only allows a short
amount of the track to play unless the length of the
track is input as a delay and then it plays the track
in an infinite loop.
The function desired is
track is played when pin 0 is shorted
track is played again when pin 0 is shorted
What am I missing?
Thanks
Allen in Dallas
Working on getting a PIR sensor to fire an MP3 player.
I tried the code at
https://learn.sparkfun.com/tutorials/mp ... eld-hookup
This will play track 1 when pin 0 is shorted to ground
but shorting pin 0 again does nothing. One can short pin 0
get the track to play then short pin 2 and get results
and then short pin 1 and get results but shorting pin 1
repeatedly only provides results the first time.
So I wrote code but the code I wrote only allows a short
amount of the track to play unless the length of the
track is input as a delay and then it plays the track
in an infinite loop.
The function desired is
track is played when pin 0 is shorted
track is played again when pin 0 is shorted
What am I missing?
Thanks
Allen in Dallas
Code: Select all
#include <SPI.h>
#include <SdFat.h>
#include <SdFatUtil.h>
#include <SFEMP3Shield.h>
SdFat sd;
SFEMP3Shield MP3player;
int triggerPin = 0;
void setup() {
Serial.begin(9600);
//start the shield
sd.begin(SD_SEL, SPI_HALF_SPEED);
MP3player.begin();
//start playing track 1
MP3player.playTrack(1);
delay(6000);
MP3player.playTrack(1);
}
//do something else now
void loop() {
}