Music Maker MP3 Shield not working properly
Re: Music Maker MP3 Shield not working properly
Re: Music Maker MP3 Shield not working properly
Re: Music Maker MP3 Shield not working properly
Re: Music Maker MP3 Shield not working properly
Re: Music Maker MP3 Shield not working properly
Re: Music Maker MP3 Shield not working properly
//Ninjared Event Timer
#include <SPI.h>
#include <Adafruit_VS1053.h>
#include <SD.h>
#define SHIELD_RESET -1 // VS1053 reset pin (unused!)
#define SHIELD_CS 7 // VS1053 chip select pin (output)
#define SHIELD_DCS 6 // VS1053 Data/command select pin (output)
#define CARDCS 4 // Card chip select pin
#define DREQ 3 // VS1053 Data request, ideally an Interrupt pin
Adafruit_VS1053_FilePlayer musicPlayer = Adafruit_VS1053_FilePlayer(SHIELD_RESET, SHIELD_CS, SHIELD_DCS, DREQ, CARDCS);
byte eventlength = 0;
byte eventstart = 0;
int eventtimer = 0;
unsigned long timer = 0;
void setup(){
Serial.begin(9600);
musicPlayer.begin();
SD.begin(CARDCS);
musicPlayer.setVolume(20, 20);
musicPlayer.useInterrupt(VS1053_FILEPLAYER_PIN_INT);
//musicPlayer.useInterrupt(VS1053_FILEPLAYER_TIMER0_INT);
Serial.println("Timer ready");
}
void loop(){
//TIMER+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
if(millis() - timer >= 1000){
eventtimer--;
timer = millis();
Serial.println(eventtimer);
}
/* //Test for whether the timer needs to be set to run while the music is playing
while (musicPlayer.playingMusic) {
if(millis() - timer >= 1000){
eventtimer--;
timer = millis();
Serial.println(eventtimer);
}
} */
//READ THE INPUT COMMAND++++++++++++++++++++++++++++++++++++++++++++++
String input = "";
while(Serial.available() > 0){
input += (char) Serial.read();
delay(5);
}
//VALID COMMANDS++++++++++++++++++++++++++++++++++++++++++++++++++++++
if(input == "15min"){
eventtimer = 902;
eventlength = 15;
}
//BEGIN 15 MIN EVENT+++++++++++++++++++++++++++++++++++++++++++++++++++++++++
if(eventlength == 15){
if(eventtimer == 900){
musicPlayer.startPlayingFile("timer15m.wav");
}
}
}
// include SPI, MP3 and SD libraries
#include <SPI.h>
#include <Adafruit_VS1053.h>
#include <SD.h>
// These are the pins used for the breakout example
#define BREAKOUT_RESET 9 // VS1053 reset pin (output)
#define BREAKOUT_CS 10 // VS1053 chip select pin (output)
#define BREAKOUT_DCS 8 // VS1053 Data/command select pin (output)
// These are the pins used for the music maker shield
#define SHIELD_RESET -1 // VS1053 reset pin (unused!)
#define SHIELD_CS 7 // VS1053 chip select pin (output)
#define SHIELD_DCS 6 // VS1053 Data/command select pin (output)
// These are common pins between breakout and shield
#define CARDCS 4 // Card chip select pin
// DREQ should be an Int pin, see http://arduino.cc/en/Reference/attachInterrupt
#define DREQ 3 // VS1053 Data request, ideally an Interrupt pin
Adafruit_VS1053_FilePlayer musicPlayer =
// create breakout-example object!
//Adafruit_VS1053_FilePlayer(BREAKOUT_RESET, BREAKOUT_CS, BREAKOUT_DCS, DREQ, CARDCS);
// create shield-example object!
Adafruit_VS1053_FilePlayer(SHIELD_RESET, SHIELD_CS, SHIELD_DCS, DREQ, CARDCS);
////
void setup() {
Serial.begin(9600);
Serial.println("Adafruit VS1053 Library Test");
// initialise the music player
if (! musicPlayer.begin()) { // initialise the music player
Serial.println(F("Couldn't find VS1053, do you have the right pins defined?"));
while (1);
}
Serial.println(F("VS1053 found"));
musicPlayer.sineTest(0x44, 500); // Make a tone to indicate VS1053 is working
if (!SD.begin(CARDCS)) {
Serial.println(F("SD failed, or not present"));
while (1); // don't do anything more
}
Serial.println("SD OK!");
// list files
printDirectory(SD.open("/"), 0);
// Set volume for left, right channels. lower numbers == louder volume!
musicPlayer.setVolume(20,20);
/***** Two interrupt options! *******/
// This option uses timer0, this means timer1 & t2 are not required
// (so you can use 'em for Servos, etc) BUT millis() can lose time
// since we're hitchhiking on top of the millis() tracker
//musicPlayer.useInterrupt(VS1053_FILEPLAYER_TIMER0_INT);
// This option uses a pin interrupt. No timers required! But DREQ
// must be on an interrupt pin. For Uno/Duemilanove/Diecimilla
// that's Digital #2 or #3
// See http://arduino.cc/en/Reference/attachInterrupt for other pins
// *** This method is preferred
if (! musicPlayer.useInterrupt(VS1053_FILEPLAYER_PIN_INT))
Serial.println(F("DREQ pin is not an interrupt pin"));
}
void loop() {
// Alternately, we can just play an entire file at once
// This doesn't happen in the background, instead, the entire
// file is played and the program will continue when it's done!
musicPlayer.playFullFile("track001.ogg");
// Start playing a file, then we can do stuff while waiting for it to finish
if (! musicPlayer.startPlayingFile("track001.mp3")) {
Serial.println("Could not open file track001.mp3");
while (1);
}
Serial.println(F("Started playing"));
while (musicPlayer.playingMusic) {
// file is now playing in the 'background' so now's a good time
// to do something else like handling LEDs or buttons :)
Serial.print(".");
delay(1000);
}
Serial.println("Done playing music");
}
/// File listing helper
void printDirectory(File dir, int numTabs) {
while(true) {
File entry = dir.openNextFile();
if (! entry) {
// no more files
//Serial.println("**nomorefiles**");
break;
}
for (uint8_t i=0; i<numTabs; i++) {
Serial.print('\t');
}
Serial.print(entry.name());
if (entry.isDirectory()) {
Serial.println("/");
printDirectory(entry, numTabs+1);
} else {
// files have sizes, directories do not
Serial.print("\t\t");
Serial.println(entry.size(), DEC);
}
entry.close();
}
}
Re: Music Maker MP3 Shield not working properly
Re: Music Maker MP3 Shield not working properly
// include SPI, MP3 and SD libraries
#include <SPI.h>
#include <Adafruit_VS1053.h>
#include <SD.h>
// define the pins used
//#define CLK 13 // SPI Clock, shared with SD card
//#define MISO 12 // Input data, from VS1053/SD card
//#define MOSI 11 // Output data, to VS1053/SD card
// Connect CLK, MISO and MOSI to hardware SPI pins.
// See http://arduino.cc/en/Reference/SPI "Connections"
// These are the pins used for the breakout example
//#define BREAKOUT_RESET 9 // VS1053 reset pin (output)
//#define BREAKOUT_CS 10 // VS1053 chip select pin (output)
//#define BREAKOUT_DCS 8 // VS1053 Data/command select pin (output)
// These are the pins used for the music maker shield
#define SHIELD_CS 7 // VS1053 chip select pin (output)
#define SHIELD_DCS 6 // VS1053 Data/command select pin (output)
#define SHIELD_RESET -1 // (my addition!)
// These are common pins between breakout and shield
#define CARDCS 4 // Card chip select pin
// DREQ should be an Int pin, see http://arduino.cc/en/Reference/attachInterrupt
#define DREQ 3 // VS1053 Data request, ideally an Interrupt pin
Adafruit_VS1053_FilePlayer musicPlayer =
// create breakout-example object!
// Adafruit_VS1053_FilePlayer(BREAKOUT_RESET, BREAKOUT_CS, BREAKOUT_DCS, DREQ, CARDCS);
// create shield-example object!
Adafruit_VS1053_FilePlayer(SHIELD_RESET, SHIELD_CS, SHIELD_DCS, DREQ, CARDCS);
// Adafruit_VS1053_FilePlayer(SHIELD_CS, SHIELD_DCS, DREQ, CARDCS);
This gave an error " player_simple:45: error: 'SHIELD_RESET' was not declared in this scope"
so I added the line:
#define SHIELD_RESET -1 // (my addition!)
The sketch will upload, but the files does not play, and I keep getting
" Couldn't find VS1053, do you have the right pins defined? " error.
I am using an Arduino Mega 2560. I have soldered the 3 SPI jumpers per the instructions. Do I need to
change the SPI code:
// define the pins used
//#define CLK 13 // SPI Clock, shared with SD card
//#define MISO 12 // Input data, from VS1053/SD card
//#define MOSI 11 // Output data, to VS1053/SD card
// Connect CLK, MISO and MOSI to hardware SPI pins.
// See http://arduino.cc/en/Reference/SPI "Connections"
Re: Music Maker MP3 Shield not working properly
Re: Music Maker MP3 Shield not working properly
Re: Music Maker MP3 Shield not working properly
Re: Music Maker MP3 Shield not working properly
Re: Music Maker MP3 Shield not working properly
Re: Music Maker MP3 Shield not working properly