Pages: [1]   Go Down
Author Topic: Help with Adafruit wave shield 1.1 with Arduino 0022?  (Read 903 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 11
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Noob here.  Just assembled a wave shield, formatted SD card, loaded some .wav files, downloaded the AF_Wave libraries and tried to run this code:
Code:
#include <AF_Wave.h>
#include <avr/pgmspace.h>
#include "util.h"
#include "wave.h"

AF_Wave card;
File f;
Wavefile wave;      // only one!

#define redled 9

uint16_t samplerate;

void setup() {
  Serial.begin(9600);           // set up Serial library at 9600 bps
  Serial.println("Wave test!");

  pinMode(2, OUTPUT);
  pinMode(3, OUTPUT);
  pinMode(4, OUTPUT);
  pinMode(5, OUTPUT);
  pinMode(redled, OUTPUT);
 
  if (!card.init_card()) {
    putstring_nl("Card init. failed!"); return;
  }
  if (!card.open_partition()) {
    putstring_nl("No partition!"); return;
  }
  if (!card.open_filesys()) {
    putstring_nl("Couldn't open filesys"); return;
  }

 if (!card.open_rootdir()) {
    putstring_nl("Couldn't open dir"); return;
  }

  putstring_nl("Files found:");
  ls();
}

void ls() {
  char name[13];
  int ret;
 
  card.reset_dir();
  putstring_nl("Files found:");
  while (1) {
    ret = card.get_next_name_in_dir(name);
    if (!ret) {
       card.reset_dir();
       return;
    }
    Serial.println(name);
  }
}

uint8_t tracknum = 0;

void loop() {
   uint8_t i, r;
   char c, name[15];


   card.reset_dir();
   // scroll through the files in the directory
   for (i=0; i<tracknum+1; i++) {
     r = card.get_next_name_in_dir(name);
     if (!r) {
       // ran out of tracks! start over
       tracknum = 0;
       return;
     }
   }
   putstring("\n\rPlaying "); Serial.print(name);
   // reset the directory so we can find the file
   card.reset_dir();
   playcomplete(name);
   tracknum++;
}

void playcomplete(char *name) {
  uint16_t potval;
  uint32_t newsamplerate;
 
  playfile(name);
  samplerate = wave.dwSamplesPerSec;
  while (wave.isplaying) {     
// you can do stuff here!
delay(500);
   }
  card.close_file(f);
}

void playfile(char *name) {
   f = card.open_file(name);
   if (!f) {
      putstring_nl(" Couldn't open file"); return;
   }
   if (!wave.create(f)) {
     putstring_nl(" Not a valid WAV"); return;
   }
   // ok time to play!
   wave.play();
}

But no audio plays back and receive this in the Serial Monitor:
Code:
Wave test!
Card init. failed!
Help?
Logged

Manchester (England England)
Online Online
Brattain Member
*****
Karma: 597
Posts: 33297
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Is the SD card formatted correctly?
Is it a 2G one, I think there is trouble with some older smaller cards.
Have you soldered all the joints, inspect them very closely some might look soldered but close inspection will show they are not.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 11
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

All of the solders appear good. 
The card is formatted correctly, at least according to the instructions on the Adafruit site.
But, it was a 2G Micro.
Just tested it with another SD card and returned the same error. 

Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 11
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

So I downloaded the WaveHC library and ran a test.
Got this in the Serial Monitor:
Code:
card.init failed
SD error
errorCode: 1
errorData: 0
Logged

Manchester (England England)
Online Online
Brattain Member
*****
Karma: 597
Posts: 33297
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

It is either the SD card or more likely a construction error. I can't think of anything else. These things do work. Can you check the signals on an oscilloscope, it might point to the connection with the error.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 11
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Got it!  It was a bad solder somewhere.  Everything looked good and nothing showed up with a multimeter test.  So I went back through and hit any questionable welds with an iron.  Sound!
Thanks for the help!
Logged

Pages: [1]   Go Up
Jump to: