Home Forums Sparkfun MP3 Shield Library Support Forum Library and Ultrasonic Sensors

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
  • #1852

    From an email I got

    Mr. Porter,

    I am using your MP3 Shield library with my Arduino Uno for my Senior Design Project at the University of Utah.  Your library works great, thanks for putting that together!  I am a Mechanical Engineer and am gaining experience with electronics as I go.

    I am using two ultrasonic rangefinders and three infrared rangefinders simultaneously with the MP3 Shield and am running into a problem and I was hoping you could help me figure out what the issue is.

    The sensors work very well when they are all hooked up together, however, as soon as I start the MP3 Shield and begin playing music simultaneously with the sensors, the sensor readings become sporadic.  I have checked voltage levels across all of the sensors and that is not the issue.  I suspect that the analog readings I am getting from the ultrasonic sensors are somehow altered by the MP3 Shield operation, could this be?

    Do you have any ideas as to why the sensor readings become inaccurate when operating simultaneously with the MP3 Shield?





    Give us more details on the types of sensors you are using and what code runs them. Are you sure they are analog sensors and not PWM output? I can see a problem trying to use PWM input sensors with the MP3 library as there would be simultaneous interrupt conflicts. However pure analog sensors should not interfere with the MP3 functions.

    Try wrapping your sensor code in the MP3 data stream functions, like this:


     //disable interrupts to avoid collisions on the SPI bus between this code //and the MP3player library
      //Sensor code here, for example if it's a PWM sensor
      digitalWrite(TRIG_PIN, HIGH); // Send a 10uS high to trigger ranging
      digitalWrite(TRIG_PIN, LOW);
      // Now ping for objects
      int distance = pulseIn(ECHO_PIN, HIGH);        // Read in times pulse
      //enable interrupts to resume sending data to MP3 shield

    That’s what it would look like if you had a PWM based sensor.

Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.