- Sun Jan 18, 2015 5:14 pm
#178824
Hello SparkFun Forum,
OK last question.
The MP3 sketches in the Examples library (File Player
and MP3Shield_Library_Demo) both (I think) require
input via the Serial Monitor to get a track to play.
The application envisioned would use a signal
from a PIR Sensor to take a Pin 1 low to play
track001.mp3.
So I put together a sketch (code below) to
do that but I get
sketch_jan18a.ino: In function 'void loop()':
sketch_jan18a.ino:28:5: error: 'MP3player' was not declared in this scope
1. Not sure what "In function 'void loop()':" means?
2. The function MP3player is declared in the include
<SFEMP3Shield.h> so it seems like it is declared by reference.
Have looked for a simple MP3 shield player ino
but the two example files are several hundred lines
long so it is hard to boil them down t simplicity.
Thanks.
Allen in Dallas
OK last question.
The MP3 sketches in the Examples library (File Player
and MP3Shield_Library_Demo) both (I think) require
input via the Serial Monitor to get a track to play.
The application envisioned would use a signal
from a PIR Sensor to take a Pin 1 low to play
track001.mp3.
So I put together a sketch (code below) to
do that but I get
sketch_jan18a.ino: In function 'void loop()':
sketch_jan18a.ino:28:5: error: 'MP3player' was not declared in this scope
1. Not sure what "In function 'void loop()':" means?
2. The function MP3player is declared in the include
<SFEMP3Shield.h> so it seems like it is declared by reference.
Have looked for a simple MP3 shield player ino
but the two example files are several hundred lines
long so it is hard to boil them down t simplicity.
Thanks.
Allen in Dallas
Code: Select all
/**
* \file MP3Shield_Play_From_Pin_Low.ino
* This sketch plays a track when the digital pin is set to low.
* For instance, when Pin O is grounded the MP3 Shield plays track001.mp3
* Sketch assumes you have MP3 files with filenames like "track001.mp3",
* "track002.mp3", etc on an SD card loaded into the shield.
*/
#include <SPI.h>
//Add the SdFat Libraries
#include <SdFat.h>
#include <SdFatUtil.h>
//and the MP3 Shield Library
#include <SFEMP3Shield.h>
void setup() {
pinMode(0, INPUT);
pinMode(1, INPUT);
}
void loop() {
// main code here, to run repeatedly:
if (0 == LOW)
{
MP3player.playTrack(1)
}
}