Hello, I am trying to play an mp3 file with an mp3 s hield from sparkfun and an ultrasonic sensor for a school project. I an very new to this stuff and have no idea what I am doing. I got this code off the internet and I got an error saying I don't have SdFat.h and so I downloaded the library for that, but now I don't have SdFatUtil.h and I can't find the library for it and its not in the SdFat library. Can someone please tell me where to find this.
Code that I found on the internet (no idea if this is actually what I need)
\
#include <SPI.h>
#include <SdFat.h>
#include <SdFatUtil.h>
#include <SFEMP3Shield.h>
/*
*This project triggers an MP3 when a short-range ultra-sonic
*sensor is triggered. Tested on a VS1053 MP3 shield and
*Virtuabotix ultrasonic distance rangefinder.
*/
SdFat sd;
SFEMP3Shield MP3player;
#define trigPin 5
#define echoPin 4
void setup() {
Serial.begin(9600);
delay(3000);
pinMode(trigPin, OUTPUT);
pinMode(echoPin, INPUT);
//start the shield
sd.begin(SD_SEL, SPI_HALF_SPEED);
MP3player.begin();
MP3player.setVolume(0);
}
void loop() {
long duration, distance;
long avgDistance = 0;
/*
*Currently receiving an invalid reading every fourth attempt.
*This loop averages out the readings to compensate for this.
*/
for(int i=0; i<4; i++){
digitalWrite(trigPin, HIGH);
delayMicroseconds(1000);
digitalWrite(trigPin, LOW);
duration = pulseIn(echoPin, HIGH);
//Convert to centimeters
distance = (duration/2)/29;
//Serial.print(distance);
//Serial.println("cm");
avgDistance += distance;
delay(50);
}
avgDistance = (avgDistance/4);
Serial.print(avgDistance);
Serial.println("cm");
if(avgDistance < 20 && avgDistance > 0){
//Tracks need to be named in the following manner on the sd card:
//track00x.mp3, where x is the track number. Track 1 is being played below.
MP3player.playTrack(1);
delay(20000);
}
}
I do that and it doesn't show up anywhere and I still get the error. I then go to: file / preferences / then select the file and location but nothing happens, other than I am now getting the SdFat.h no file found error, but I have also downloaded that library as well.
The IDE ("the Arduino program") should be Closed when installing a library 'manually'.
If the IDE is 'up' and a library is installed manually, the 'IDE' will not find it till it's re-started.
I don't have the Arduino mp3 shield, so I can't test it and its libraries. But in what little I have seen on the net, the SdFat.h library is used but not the SdFatUtil.h.
I advise you to examine this PAGE thoroughly and try to execute some example of the ones that the library that indicates to use brings, once it works, adding the ultrasonic sensor will be an easy task.
How do I edit the code so that the code doesn't use 'SdFatUtil.h'?
Also, when I go to add a library I do this : sketch / include library / add .ZIP library / downloads (that is where the file is) / select SD-master (I have tried this with and without extracting the files)
and either way I end up not seeing the library in added libraries.
Ok, I have finally figured out how to got the libraries into my sketches and it is using the sketch book, just manually moving the files over to the sketchbook folder in files, opening up arduino and bam, it works.
Thank you all for your help, it was much appreciated.
(I am just editing this post because I am out of new posts for today).