Pages: [1]   Go Down
Author Topic: Help with Elechouse MP3 Shield  (Read 149 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Karma: 0
Posts: 2
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
URM37 v3.2 Ultrasonic Sensor

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++
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
void loop()
}                      //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++){
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.
      Distance=DistanceMeasured/50;           // every 50us low level stands for 1cm
  if((Distance > RangeLow) && (Distance < RangeHigh))
          digitalWrite(led, HIGH);
          digitalWrite(led, LOW);

#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 */
  /** set MP3 Shield CYCLE mode */
  /** play music in sd, '0001' for first music */

void loop()

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

Pages: [1]   Go Up
Jump to: