Help with Elechouse MP3 Shield

Dear community,

recently started to explore the beautiful world of Arduino. Now I reached the point where i need your advice.

What I want to create
A stationary device that should play music while a person is standing or moving within a predefined distance from the sensor. As soon the person leaves the area the playback should be paused and as soon someone is again within the range, the playback should be continued (of course from the same point of the track). Activation range: 20 to 400 cm. So as long as the predefined area is empty the playback is on hold. Playback from a 4GB USB stick.

What I have
Arduino UNO R3
Arduino USB-SD MP3 Shield from Elechouse http://www.elechouse.com/elechouse/index.php?main_page=product_info&cPath=168_170&products_id=2193
URM37 v3.2 Ultrasonic Sensor http://www.elechouse.com/elechouse/index.php?main_page=product_info&cPath=168_170&products_id=2193

What am I able to do right now
Measure the distance with the URM37 and lighting a LED if s.o. is within the predefined range
Playing tracks from a USB stick (both at the same time)
Really basic C++
Wiring+soldering
Following your advices
Reading tutorials

Distance measuring with LED lightup

// # Editor    :Jiang from DFRobot
// # Data      :18.09.2012
 
// # Product name:ultrasonic scanner
// # Product SKU:SEN0001
// # Version :  0.2
 
// # Description:
// # The Sketch for scanning 180 degree area 4-500cm detecting range
 
// # Connection:
// #       Pin 1 VCC (URM V3.2) -> VCC (Arduino)
// #       Pin 2 GND (URM V3.2) -> GND (Arduino)
// #       Pin 4 PWM (URM V3.2) -> Pin 3 (Arduino)
// #       Pin 6 COMP/TRIG (URM V3.2) -> Pin 5 (Arduino)
// #
int URPWM = 3; // PWM Output 0?25000US?Every 50US represent 1cm
int URTRIG=5; // PWM trigger pin
int RangeLow = 20;
int RangeHigh = 400;
int led = 13;

unsigned int Distance=0;
uint8_t EnPwmCmd[4]={0x44,0x02,0xbb,0x01};    // distance measure command
 
void setup(){                                 // Serial initialization
  pinMode(led, OUTPUT);
  Serial.begin(9600);                         // Sets the baud rate to 9600
  PWM_Mode_Setup();
}
 
void loop()
{
 PWM_Mode();
 delay(20);
}                      //PWM mode setup function
 
void PWM_Mode_Setup(){
  pinMode(URTRIG,OUTPUT);                     // A low pull on pin COMP/TRIG
  digitalWrite(URTRIG,HIGH);                  // Set to HIGH
  
  pinMode(URPWM, INPUT);                      // Sending Enable PWM mode command
  
  for(int i=0;i<4;i++){
      Serial.write(EnPwmCmd[i]);
   }
}
 
void PWM_Mode(){                              // a low pull on pin COMP/TRIG  triggering a sensor reading
    digitalWrite(URTRIG, LOW);
    digitalWrite(URTRIG, HIGH);               // reading Pin PWM will output pulses
     
    unsigned long DistanceMeasured=pulseIn(URPWM,LOW);
     
    if(DistanceMeasured==50000){              // the reading is invalid.
      Serial.print("Invalid");   
   }
    else{
      Distance=DistanceMeasured/50;           // every 50us low level stands for 1cm
   }
  Serial.print("Distance=");
  Serial.print(Distance);
  Serial.println("cm");
  
  if((Distance > RangeLow) && (Distance < RangeHigh))
       {
          digitalWrite(led, HIGH);
       }
       else
       {
          digitalWrite(led, LOW); 
       }
}

Playback

#include <SoftwareSerial.h>
#include <MP3.h>

/** define mp3 class */
MP3 mp3;

void setup()
{
  /** begin function */
  mp3.begin(MP3_SOFTWARE_SERIAL);    // select software serial
  
  /** set volum to the MAX */
  mp3.volume(0x1F);
  
  /** set MP3 Shield CYCLE mode */
  mp3.set_mode(MP3::CYCLE);
  
  /** play music in sd, '0001' for first music */
  mp3.play_usb_disk(0x0001);
  
}

void loop()
{
  mp3.volume(0x1F);
  //mp3.set_mode(MP3::CYCLE);
  mp3.play_usb_disk(0x0001);
}

Basicly i need a if-loop or a while-loop to control the MP3 Shield.

Any kind of replies is welcome!
Sorry for my bad English smiley-sad

Guys, can i know is it possible to change the track of mp3 shield like that?

int onPin = 37;
int songinput;

if (songinput == HIGH)
{

/** select SD card first music and play */
cmd_buf[0] = 0x7E; // START
cmd_buf[1] = 0x04; // Length
cmd_buf[2] = 0xA2; // Command For U Disk change this line to 0xA2
cmd_buf[3] = 0x00; // file number high byte
cmd_buf[4] = 0x01; // file number low byte
cmd_buf[5] = 0x7E; // END
ArduinoMP3Shield_SendCMD(cmd_buf, 6);

}