Adafruit MP3 shield and Ultrasonic Sensor

Hey all!! First time poster. I'm working on an installation making audio players with Arduino Uno and an Adafruit MP3 shield that are motion activated with an ultrasonic sensor. I've done something similar before but to be honest I'm a little rusty.

The pictures I have from the previous exhibit show the ultrasonic sensor jumpers running either to or through the mp3 shield, but I can't tell if they're pulling from the same 5V as the mp3 shield or if there's a relay that I'm not seeing. I didn't want to fry the Arduino I have by testing it out, and I attached a photo I have of the original installation for reference.

I'm also seeing online that the shield i have does not have an amp, so that's another addon pulling power.

Anyway thank you for reading!!

And what is your question?

Sorry for not being clear, my question is if the Arduino Uno can power both the adafruit mp3 shield and the ultrasonic sensor by itself, and if so can I solder to the same 5V and ground or do I need a relay module. The picture is from the previous time I did this and I'm having trouble deciphering how exactly I wired it.

And secondary question is if I can add an amplifier module on top of all that.

As I said I'm a little rusty so I think taking out the pins the shield doesn't need is confusing me and I'm worried about potentially wiring the power wrong.

Hope that makes sense!

I think you're a bit confused.
Firstly, if you're powering the modules from the same 5V and ground as the Arduino, that doesn't mean it "powered by Arduino".
And secondly, relay is not an alternative to a power supply. A relay can turn the module on and off, but it anyway needs power—and you still haven't said what kind.
To answer correctly, we need to know the model of the MP3 board and the sensors, as it's not always clear from the picture.

Yes, I'm sorry I am a bit confused, trying my best to explain. I have the Adafruit "Music Maker" Mp3 Shield (the VS1053) attached to the Arduino Uno R3. I'm trying to attach the Ultrasonic Sensor from the Super Starter Kit Uno R3. Right now the Arduino is just powered through usb connection to my computer but I have Elegoo AC-DC adaptors (Input: AC 100-240V 50/60Hz 0.25A Output: DC 9V) I can get a different power supply if needed, I just want to make sure I'm connecting the Ultrasonic Sensor to the Arduino appropriately. Here's my previous code for reference:

// 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_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

const int pingPin = 2; // Trigger Pin of Ultrasonic Sensor
const int echoPin = 5; // Echo Pin of Ultrasonic Sensor

// SOUND PLAYBACK VARIABLES
int currentFile = 0;
int pauseTime = 0; // How long has it been paused?
int waitTime = 10; // How many seconds to stay paused before stopping?
// Currently, ten sound files to consider playing.
// This is the list of their names.
char *soundFiles[] = {"/track001.ogg", "/track002.ogg", "/track003.ogg", "/track004.ogg", "/track005.ogg",
                     "/track006.ogg", "/track007.ogg", "/track008.ogg", "/track009.ogg" } ;

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 Simple Test");

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

  if (!SD.begin(CARDCS)) {
    Serial.println(F("SD failed, or not present"));
    while (1);  // don't do anything more
  }

  // Geers really doesn't think this is needed...
  // printDirectory(SD.open("/"), 0);

  // Set volume for left, right channels. lower numbers == louder volume!
  musicPlayer.setVolume(20, 20);
  
  // 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

  // CONVERT waitTime from seconds to milliseconds:
  waitTime = waitTime * 1000;
}

// MAIN CODE LOOP
void loop() {
  // Define some variables:
  long duration, inches;

  // GET SENSOR DISTANCE reading
  pinMode(pingPin, OUTPUT);
  digitalWrite(pingPin, LOW);
  delayMicroseconds(2);
  digitalWrite(pingPin, HIGH);
  delayMicroseconds(10);
  digitalWrite(pingPin, LOW);
  pinMode(echoPin, INPUT);
  duration = pulseIn(echoPin, HIGH);
  inches = microsecondsToInches(duration);
  Serial.print(inches);
  Serial.print("in, ");
  Serial.println();
  // delay(100);

  //then check the distance and play file 1,2,3,4,5,6,7,8 if it's in the range
  if (inches >= 200 || inches <= 0) {
    Serial.println("Out of range");
  }
  else if (inches < 48) {
    if (musicPlayer.stopped() == 1) {
      // If player was stopped, look to see what is next file to play, and start it.
      // NOTICE: Now instead of putting in actual sound file name, we use a variable.
      musicPlayer.playFullFile(soundFiles[currentFile]);
      // Tell human what file we're playing
      Serial.print("Starting to play ");
      Serial.println(soundFiles[currentFile]);
    }
    else if (musicPlayer.paused() == 1) {
      // If player was paused, then continue playing current sound file.
      musicPlayer.playFullFile(soundFiles[currentFile]);
    }
    // Reset wait time, since we're not waiting to play sound any longer.
    waitTime = 0; // reset wait time to zero.  we're not waiting now...
    // Print some info to human user:
    Serial.print(inches);
    Serial.println(" inches");
  }
  else {
    // If no one is close, pause or stop playback.
    // first, check if it is already paused.  If not, pause it.
    if (musicPlayer.paused() == 0) {
      // Serial.print(inches);
      Serial.println("Playback is PAUSED.");
      musicPlayer.pausePlaying(true);
    }
    else if (pauseTime > waitTime) {
      // If it is already paused, check how long it has been paused. If too long, stop the file.
           Serial.println("Playback has STOPPED.");
      musicPlayer.stopPlaying();
      // increment "currentFile" variable to point to next one in the series.
      currentFile = currentFile + 1;
      // If we're counting beyond actual # of files, reset to file #0, the first one.
      if (currentFile > 9) {
        currentFile = 0;
      }
    }
  }
  delay(2000); // Wait some bit of time before we check sensor again.

  // If we are paused, increment waitTime variable the duration in delay command above.
  if (musicPlayer.paused() == 1) {
    waitTime = waitTime + 2000;
  }
}
// END OF MAIN LOOP ** END OF MAIN LOOP
// END OF MAIN LOOP ** END OF MAIN LOOP





/// File listing helper code
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();
  }
}

long microsecondsToInches(long microseconds) {
  return microseconds / 74 / 2;
}

long microsecondsToCentimeters(long microseconds) {
  return microseconds / 29 / 2;
}

The first is better than the second.
The thing is, the Arduino Uno uses 5V. When you connect a higher-voltage power source to round DC connector, you use the board's built-in regulator to step down the voltage from 9V to the 5V. This regulator has a small current rate and is not designed to power any modules other than the board itself
And in case of shields, it will be powered directly by the Arduino board.

So the better way is to use a USB connector or DC 5v power supply; in last case you have to connect it to "5v" and "GND" Uno pins rather than to DC connector.

Given that you have no confident recollection of your similar previous circuit, I would first get it working on breadboard before soldering.

I have no experience of the Adafruit MP3 shield or its library. If you think my Uno/Nano playing MP3s with the DFR MP3 Player activated by a PIR sensor would help, I'll dig it out and post it.

Meanwhile you've posted insufficient detail. Do you have no schematic or sketch from the previous project? Nor anything yet for the current one?