hello everybody,
i have an problem with the waveshield for arduino.
the sketch on ladyada to play all files in root directory works fine.
now i want to build it in my own code which uses GPS data to figure out what file it should play....
but always i get only :"couldn't open 2.wav or 6 or 7.wav..... etc.
the files are used in void vergleich();
here is my code:
#include <string.h>
#include <ctype.h>
#include <FatReader.h>
#include <SdReader.h>
#include <avr/pgmspace.h>
#include "WaveUtil.h"
#include "WaveHC.h"
int ledpin = 13; // LED test pin
char speicher[80];
char Breitengrad[10];
char Laengengrad[11];
char BG[13];
char LG[14];
char *ptr, *ptr2;
float Bgrad, Lgrad;
int i,x,y,z;
SdReader card; // This object holds the information for the card
FatVolume vol; // This holds the information for the partition on the card
FatReader root; // This holds the information for the filesystem on the card
FatReader f; // This holds the information for the file we're play
WaveHC wave; // This is the only wave (audio) object, since we will only play one at a time
void setup(){
pinMode(ledpin, OUTPUT);
Serial.begin(9600);
Serial1.begin(4800);
pinMode(2, OUTPUT);
pinMode(3, OUTPUT);
pinMode(4, OUTPUT);
pinMode(5, OUTPUT);
}
void loop(){
rechnen();
if(z==1)
{
vergleich();
z=0;
}
}
void rechnen()
{
if(x==3)
{
double B=atof(Breitengrad);
//Serial.println(B,DEC);
double L=atof(Laengengrad);
//Serial.println(L,DEC);
Bgrad=(int(B / 100) + (B - (int(B / 100) * 100)) / 60);
Lgrad=(int(L / 100) + (L - (int(L / 100) * 100)) / 60);
//Serial.println(Bgrad,DEC);
//Serial.println(Lgrad,DEC);
x=0;
y++;
z++;
}
}
void vergleich()
{
if(y==1)
{
if(Bgrad < 51.52019 && Bgrad > 51.51924 )
{
if(Lgrad < 7.48888 && Lgrad > 7.48838)
{
Serial.println("Klönnesstraße Ecke Hernebachstraße");
playcomplete("15.WAV");
}
}
if(Bgrad < 51.51972 && Bgrad > 51.51897 )
{
if(Lgrad < 7.48857 && Lgrad > 7.48785)
{
Serial.println("Klönnestraße an der Jet Tankstelle");
playcomplete("16.WAV");
}
}
if(Bgrad < 51.51897 && Bgrad > 51.51822 )
{
if(Lgrad < 7.48818 && Lgrad > 7.48755)
{
Serial.println("Klönnestraße Ecke Inselstraße");
playcomplete("19.WAV");
}
}
if(Bgrad < 51.51821 && Bgrad > 51.5176 )
{
if(Lgrad < 7.48794 && Lgrad > 7.48745)
{
Serial.println("Klönnestraße Kreuz Eisenachestraße/Hallesdestraße");
playcomplete("20.WAV");
}
}
if(Bgrad <51.51760 && Bgrad > 51.51693 )
{
if(Lgrad < 7.48793 && Lgrad > 7.48744)
{
Serial.println("Klönnestraße Ecke Heimbaustraße");
playcomplete("18.WAV");
}
}
if(Bgrad <51.51693 && Bgrad > 51.51636 )
{
if(Lgrad < 7.48799 && Lgrad > 7.4875)
{
Serial.println("Klönnestraße Ecke Güntherstraße");
playcomplete("17.WAV");
}
}
if(Bgrad < 51.5183 && Bgrad > 51.51793 )
{
if(Lgrad < 7.48759 && Lgrad > 7.4865)
{
Serial.println("Eisenacher Straße Ecke Klönnestraße");
playcomplete("5.WAV");
}
}
if(Bgrad < 51.51831 && Bgrad > 51.51752 )
{
if(Lgrad < 7.4865 && Lgrad > 7.48422)
{
Serial.println("Eisenacher Straße Mitte");
playcomplete("6.WAV");
}
}
if(Bgrad < 51.51766 && Bgrad > 51.51635 )
{
if(Lgrad < 7.48377 && Lgrad > 7.48235)
{
Serial.println("Eisenacher Straße Ecke Güntherstraße");
playcomplete("4.WAV");
}
}
if(Bgrad < 51.52 && Bgrad > 51.51969 )
{
if(Lgrad < 7.48637 && Lgrad > 7.48482)
{
Serial.println("Körnebachstraße Ecke Inselstraße");
playcomplete("21.WAV");
}
}
if(Bgrad < 51.52019 && Bgrad > 51.51986 )
{
if(Lgrad < 7.48774 && Lgrad > 7.48637)
{
Serial.println("Körnebachstraße Mitte");
playcomplete("23.WAV");
}
}
if(Bgrad < 51.52034 && Bgrad > 51.52005 )
{
if(Lgrad < 7.48866 && Lgrad > 7.48774)
{
Serial.println("Körnebachstraße Ecke Klönnestraße");
playcomplete("22.WAV");
}
}
if(Bgrad < 51.51969 && Bgrad > 51.5191 )
{
if(Lgrad < 7.48575 && Lgrad > 7.48483)
{
Serial.println("Inselstraße Ecke Körnebachstraße");
playcomplete("14.WAV");
}
}
if(Bgrad < 51.51935 && Bgrad > 51.866 )
{
if(Lgrad < 7.48678 && Lgrad > 7.48575)
{
Serial.println("Inselstraße Mitte");
playcomplete("29.WAV");
}
}
if(Bgrad < 51.51893 && Bgrad > 51.51826 )
{
if(Lgrad < 7.48759 && Lgrad > 7.48678)
{
Serial.println("Inselstraße Ecke Klönnestraße");
playcomplete("13.WAV");
}
}
if(Bgrad <51.52151 && Bgrad > 51.52034 )
{
if(Lgrad < 7.48892 && Lgrad > 7.48819)
{
Serial.println("Im Spähenfelde Anfang Klönnestraße");
playcomplete("12.WAV");
}
}
if(Bgrad <51.52268 && Bgrad >51.52151 )
{
if(Lgrad < 7.48872 && Lgrad > 7.48773)
{
Serial.println("Im Spähefelde Mitte");
playcomplete("11.WAV");
}
}
if(Bgrad <51.5238 && Bgrad >51.52268 )
{
if(Lgrad < 7.48828 && Lgrad > 7.48647)
{
Serial.println("Im Spähefelde Ecke Brachder Straße");
playcomplete("10.WAV");
}
}
if(Bgrad <51.51769 && Bgrad >51.51768 )
{
if(Lgrad < 7.49015 && Lgrad > 7.48944)
{
Serial.println("Lüneburgerstraße Ecke Güntherstraße");
playcomplete("24.WAV");
}
}
if(Bgrad <51.52057 && Bgrad >51.51952 )
{
if(Lgrad < 7.49132 && Lgrad > 7.48946)
{
Serial.println("Zinkhüttenweg");
playcomplete("27.WAV");
}
}
if(Bgrad < 51.51829 && Bgrad > 51.51796 )
{
if(Lgrad < 7.48879 && Lgrad > 7.48775)
{
Serial.println("Halleschestraße Ecke Klönnestraße");
playcomplete("1.WAV");
}
}
if(Bgrad < 51.51827 && Bgrad > 51.51799 )
{
if(Lgrad < 7.49045 && Lgrad > 7.4888)
{
Serial.println("Halleschestraße Kreuz Lüneburgstraße");
playcomplete("3.WAV");
}
}
if(Bgrad < 51.51819 && Bgrad > 51.51784 )
{
if(Lgrad < 7.49207 && Lgrad > 7.49045)
{
Serial.println("Halleschestraße Mitte");
playcomplete("2.WAV");
}
}
if(Bgrad < 51.52029 && Bgrad > 51.51926 )
{
if(Lgrad < 7.48487 && Lgrad > 7.48322)
{
Serial.println("Westfalen Akademie Parkplatz");
playcomplete("26.WAV");
}
}
if(Bgrad < 51.51742 && Bgrad > 51.51701 )
{
if(Lgrad < 7.48761 && Lgrad > 7.48652)
{
Serial.println("Heimbaustraße Ecke Klönnestraße");
playcomplete("8.WAV");
}
}
if(Bgrad < 51.51741 && Bgrad > 51.51700 )
{
if(Lgrad < 7.48652 && Lgrad > 7.48544)
{
Serial.println("Heimbaustraße Mitte");
playcomplete("9.WAV");
}
}
if(Bgrad < 51.51733 && Bgrad > 51.51699 )
{
if(Lgrad < 7.48544 && Lgrad > 7.48395)
{
Serial.println("Heimbaustraße Ecke Güntherstraße");
playcomplete("7.WAV");
}
}
if(Bgrad < 51.51648 && Bgrad > 51.51614 )
{
if(Lgrad < 7.48767 && Lgrad >7.48631)
{
Serial.println("Günther Ecke Klönnestraße");
playcomplete("28.WAV");
}
}
if(Bgrad < 51.51861 && Bgrad > 51.51769 )
{
if(Lgrad < 7.48981 && Lgrad >7.48923)
{
Serial.println("Lüneburgstraße Kreuz Halleschestraße");
playcomplete("25.WAV");
}
}
y=0;
}
else
{
Serial.println("Signal out of Range...");
delay(1000);
}
}
void playcomplete(char *name) {
// call our helper to find and play this name
playfile(name);
while (wave.isplaying) {
// do nothing while its playing
}
// now its done playing
}
void playfile(char *name) {
// see if the wave object is currently doing something
if (wave.isplaying) {// already playing something, so stop it!
wave.stop(); // stop it
}
// look in the root directory and open the file
if (!f.open(root, name)) {
putstring("Couldn't open file "); Serial.print(name); return;
}
// OK read the file and turn it into a wave object
if (!wave.create(f)) {
putstring_nl("Not a valid WAV"); return;
}
// ok time to play! start playback
wave.play();
}
hope someone could figure out where the problem is....
thx a lot 4 help
ben