got the Adafruit Music Maker MP3 Shield for Arduino with 3W Stereo Amp working and playing music but when i say
s to stop or p' on the serial console, pause/unpause! but it dont work
i try to button to start and stop but look ther no code for start and try with stop but no look
can some help me on is
Adafruit Music Maker MP3 Shield serial bug and help
Moderators: adafruit_support_bill, adafruit
Please be positive and constructive with your questions and comments.
- davidwhitt46
- Posts: 9
- Joined: Thu Aug 07, 2014 3:48 pm
- Franklin97355
- Posts: 23912
- Joined: Mon Apr 21, 2008 2:33 pm
Re: Adafruit Music Maker MP3 Shield serial bug and help
Could you post your code and a description or drawing of your connections between it all? Please use the code button "</>" in the button bar when posting code to the forums.
- davidwhitt46
- Posts: 9
- Joined: Thu Aug 07, 2014 3:48 pm
Re: Adafruit Music Maker MP3 Shield serial bug and help
Code: Select all
#include <SPI.h>
#include <Adafruit_VS1053.h>
#include <SD.h>
const int doorbell = 9; // out side door bell
int buttonState = 0;
// These are the pins used for the music maker shield
#define SHIELD_RESET -1 // VS1053 reset pin (unused!)
// 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)
// 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(SHIELD_RESET, SHIELD_CS, SHIELD_DCS, DREQ, CARDCS); // create shield-example object!
//Adafruit_VS1053_FilePlayer(SHIELD_CS, SHIELD_DCS, DREQ, CARDCS);
void setup() {
Serial.begin(9600);
Serial.println("Adafruit VS1053 Simple Test");
pinMode(doorbell, INPUT);
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"));
SD.begin(CARDCS); // initialise the SD card
// Set volume for left, right channels. lower numbers == louder volume!
musicPlayer.setVolume(20,20);
// Timer interrupts are not suggested, better to use DREQ interrupt!
//musicPlayer.useInterrupt(VS1053_FILEPLAYER_TIMER0_INT); // timer int
// If DREQ is on an interrupt pin (on uno, #2 or #3) we can do background
// audio playing
musicPlayer.useInterrupt(VS1053_FILEPLAYER_PIN_INT); // DREQ int
// Play one file, don't return until complete
Serial.println(F("Playing track 001"));
musicPlayer.playFullFile("track001.mp3");
// Play another file in the background, REQUIRES interrupts!
Serial.println(F("Playing track 002"));
musicPlayer.startPlayingFile("track002.mp3");
}
void loop() {
buttonState = digitalRead(doorbell);
if (buttonState == HIGH) {
// just a test
digitalWrite(musicPlayer.startPlayingFile("track002.mp3"), HIGH); // start remdom song
}
else {
digitalWrite(musicPlayer.stopPlaying, LOW); // dont play song
}
// File is playing in the background
if (musicPlayer.stopped()) {
Serial.println("Done playing music");
while (1);
}
if (Serial.available()) {
char c = Serial.read();
// if we get an 's' on the serial console, stop!
if (c == 's')
{
musicPlayer.stopPlaying();
}
// if we get an 'p' on the serial console, pause/unpause!
if (c == 'p') {
if (! musicPlayer.paused()) {
Serial.println("Paused");
musicPlayer.pausePlaying(true);
} else {
Serial.println("Resumed");
musicPlayer.pausePlaying(false);
}
}
}
delay(100);
}
- Franklin97355
- Posts: 23912
- Joined: Mon Apr 21, 2008 2:33 pm
Re: Adafruit Music Maker MP3 Shield serial bug and help
Code: Select all
digitalWrite(musicPlayer.stopPlaying, LOW); // dont play song
Code: Select all
musicPlayer.stopPlaying();
Please be positive and constructive with your questions and comments.