Need help with Wave Shield Code!

Adafruit Ethernet, Motor, Proto, Wave, Datalogger, GPS Shields - etc!

Moderators: adafruit_support_bill, adafruit

Need help with Wave Shield Code!

Postby lbrinkworth » Thu May 03, 2012 4:25 pm

Code: Select all
#include <FatReader.h>
#include <SdReader.h>
#include <avr/pgmspace.h>
#include "WaveUtil.h"
#include "WaveHC.h"

#define songone "SONGONE.WAV"
#define songtwo "SONGTWO.WAV"
#define songthree "SONGTHREE.WAV"

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

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

int wasplaying = 0;

void sdErrorCheck(void) {
  if (!card.errorCode()) return;
  putstring("\n\rSD I/O error: ");
  Serial.print(card.errorCode(), HEX);
  putstring(", ");
  Serial.println(card.errorData(), HEX);
  while(1);
}

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);





}

void loop() {
   char c, *toplay;
   
   if (Serial.available()) {
     c = Serial.read();
Serial.println(byte(c));
     if (c == '0') {
       toplay = songone;
     }
     else if (c == '1') {
       toplay = songtwo;
     }
     else if (c == '2') {
       toplay = songthree;
     }
 
      else {
       return;
     }
     
   
   }

   
}

// Plays a full file from beginning to end with no pause.
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 ls() {
//  char name[13];
//  card.reset_dir();
//  putstring_nl("Files found:");
//  while (1) {
//    if (!card.get_next_name_in_dir(name)) {
//       card.reset_dir();
//       return;
//    }
//    Serial.println(name);
//  }
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();
}




It's not responding or playing anything, but it uploads just fine. What it's supposed to do is read the counter value from the other arduino and play the appropriate song. It's not doing that at all, also does anyone know how to make the song stop and change if the counter value suddenly changes?
lbrinkworth
 
Posts: 2
Joined: Tue Apr 24, 2012 2:46 pm

Re: Need help with Wave Shield Code!

Postby adafruit_support_bill » Thu May 03, 2012 6:07 pm

Have you verified that the wave shield works with the example code?
User avatar
adafruit_support_bill
 
Posts: 15918
Joined: Sat Feb 07, 2009 9:11 am


Return to Arduino Shields from Adafruit

Who is online

Users browsing this forum: nardev and 4 guests

Stuff to buy from the Adafruit store and links to product documentation!


New Products [102]

Raspberry Pi[80]
 
FLORA[23]
 
Bunnie Studios[9]
 
FPGA[1]
 
mbed[11]
Arduino[60]
 
NETduino[14]
 
BeagleBone[24]
 
Android[6]
 
XBee[10]
More Dev Boards[30]


 
BoArduino[8]
 
SpokePOV[4]
 
TV-B-Gone[4]
 
MiniPOV[3]
 
SIM reader[3]
 
Microtouch[5]
 
Clocks & Watches[18]
 
Drawdio[4]
 
Brain Machine[1]
 
Game of Life[2]
 
MintyBoost[2]
More DIY Kits[16]


 
MaKey MaKey[3]
 
Tweet-a-Watt[5]
 
Young Engineers[33]
 
Discover Electronics[2]
 
Snap Circuits[4]
 
littleBits[3]
 
Project packs[8]


 
Breakout Boards[33]
LCDs & Displays[48]
Components & Parts[69]
Batteries & Power[49]
EL Wire/Tape/Panel[52]
LEDs[108]
 
Wireless[14]
Cables[60]
 
Lasers[6]
Sensors/Parts[145]
 
Enclosures/Cases[11]
 
Solar[11]
 
RFID / NFC[13]
Prototyping[69]
 
iDevices[13]
Tools[71]
 
Wearables[39]
 
CNC[37]
 
Robotics[29]
 
3D printing[1]
 
Materials[24]


 
Stickers[41]
 
Skill badges[55]
 
Books[25]
 
Circuit Playground[7]
 
Gift Certificates[4]