please need help with VS1053b

Hi

I’ve been trying to get the ultrasonic sensor to work with the VS1053b

what I want is that controlling the music (on& off) depending on the distance measured
by the ultrasonic sensor!

I am using an arduino uno + music shield VS1053b

this is the code i tried , but not have worked!

i wonder if anyone can direct me as to where i am going wrong.

#include <SPI.h>
#include <Adafruit_VS1053.h>
#include <SD.h>

#define BREAKOUT_RESET 9
#define BREAKOUT_CS 10
#define BREAKOUT_DCS 8

#define SHIELD_RESET -1
#define SHIELD_CS 7
#define SHIELD_DCS 6

#define CARDCS 4
#define DREQ 3

Adafruit_VS1053_FilePlayer musicPlayer =
Adafruit_VS1053_FilePlayer(SHIELD_RESET, SHIELD_CS, SHIELD_DCS, DREQ, CARDCS);

int echoPin=12;
int trigPin=13;
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”));

SD.begin(CARDCS);
musicPlayer.setVolume(20,20);
pinMode(trigPin, OUTPUT);
pinMode(echoPin, INPUT);
}

void loop() {
float duration, distance;
digitalWrite(trigPin, HIGH);
delay(10);
digitalWrite(trigPin, LOW);
duration = pulseIn(echoPin, HIGH);
distance = duration/58;
Serial.print(distance);
Serial.println(“cm”);
if( 5 < distance || distance < 20 )
{
musicPlayer.playFullFile(“track001.mp3”);
}
else
{
musicPlayer.pausePlaying(true);
}
delay(100);
}

i wonder if anyone can direct me as to where i am going wrong.

You haven’t posted the code correctly. Please read this:-
How to use this forum

this is the code i tried , but not have worked!

You have also not said what the code actually does.

Have you got each part of the hardware working separately?