Help Combining Music Maker Code 1790 - No Amp with Class D M

General project help for Adafruit customers

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
User avatar
adafruit_support_mike
 
Posts: 67391
Joined: Thu Feb 11, 2010 2:51 pm

Re: Help Combining Music Maker Code 1790 - No Amp with Class

Post by adafruit_support_mike »

Sorry, this one fell below the bottom of the page.

The error you're getting is unusual because the value in question is defined in the Adafruit_VS1053 library. The only thing I can think of would be a garbled download.

Try deleting that library and reinstalling a fresh copy from Github.

User avatar
Larry67
 
Posts: 42
Joined: Tue May 08, 2018 2:57 pm

Re: Help Combining Music Maker Code 1790 - No Amp with Class

Post by Larry67 »

Mike

I want to close the loop on this topic. I was able to maintain maximum volume using the following code. Hope this is helpful to anyone trying to do something similar.
What I ended up doing is taking the Player Simple example and modifying the code, connecting my 9744 amplifier for digital control (even though I am not adjusting the volume for digital control) and I added a motion sensor to play a song when motion is detected. My code and the breakout boards now work independent of the computer using 9 volt power supplies. But with one caveat. I have to maintain voltage on the boards why moving them into their desired position. Not perfect, but at least I don't need the boards connected to my laptop perpetually. Fortunately I live in a location where a power outage may occur once every two years.

I set the volume to maximum in the player simple code - Volume at 1 instead of 20 that is supplied with the example. So now there is no reason for me to try and run two amplifiers in series as I posted in another question. Here is my code for anyone wanting to do something similar.

Code: Select all

// include SPI, MP3 and SD libraries
#include <SPI.h>
#include <Adafruit_VS1053.h>
#include <SD.h>

#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)

#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);

int counter = 0;
int pirSensorPin = 2;


int val = 0;
int calibrationTime = 1;


void setup() {
  pinMode(pirSensorPin, INPUT);
  Serial.begin(9600);
  Serial.println("Waiting for the sensor to warm up.");
  delay(calibrationTime * 1000); // Convert the time from seconds to milliseconds.
  Serial.println("SENSOR ACTIVE");

  Serial.println("Adafruit VS1053 Simple Test");

  musicPlayer.begin();
  SD.begin(CARDCS); 
  
  // Set volume for left, right channels. lower numbers == louder volume!
  musicPlayer.setVolume(1, 1);

  musicPlayer.useInterrupt(VS1053_FILEPLAYER_PIN_INT);  // DREQ int

  Serial.println(F("Playing track 001"));
  musicPlayer.playFullFile("track001.mp3");
  musicPlayer.playFullFile("track001.mp3");
}

void loop() {
  val = digitalRead(pirSensorPin);  // read input value

  if (val == HIGH) {            // check if the input is HIGH
    while (counter < 3) {
      Serial.println(F("Playing track 001"));
      musicPlayer.playFullFile("track001.mp3");
      delay (100);
      counter ++;
      Serial.println(counter);
    }
  }
  counter = 0;

  delay(1000);

}
Last edited by adafruit_support_mike on Tue Sep 04, 2018 3:54 am, edited 1 time in total.
Reason: fixed CODE tags

User avatar
adafruit_support_mike
 
Posts: 67391
Joined: Thu Feb 11, 2010 2:51 pm

Re: Help Combining Music Maker Code 1790 - No Amp with Class

Post by adafruit_support_mike »

Glad to hear you got things working in a way you can accept. Happy hacking!

Locked
Please be positive and constructive with your questions and comments.

Return to “General Project help”