Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.


by Surowa on Fri Feb 26, 2021 5:17 pm

Hi all,

I've succesfully assembled the wave shield and soldered it to an Arduino Uno.
Everything seems to work fine, even connecting the SD card, formatting it, putting wav files in the right compression etc.
However, the speakers, which I have soldered to the right place near the capacitor on the shield, don't output any sound.
Anything I can do?

This is the code I'm using, which is pretty much the WAV file loop which was on the tutorial earlier:
Code: Select all | TOGGLE FULL SIZE
#include <WaveUtil.h>
#include <SdReader.h>
#include <WaveHC.h>
#include <FatStructs.h>
#include <FatReader.h>
#include <SdInfo.h>
#include <mcpDac.h>
#include <WavePinDefs.h>
#include <ArduinoPins.h>

* This example plays every .WAV file it finds on the SD card in a loop
#include <WaveHC.h>
#include <WaveUtil.h>

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 volumes root directory
WaveHC wave;      // This is the only wave (audio) object, since we will only play one at a time

uint8_t dirLevel; // indent level for file/dir names    (for prettyprinting)
dir_t dirBuf;     // buffer for directory reads

* Define macro to put error messages in flash memory
#define error(msg) error_P(PSTR(msg))

// Function definitions (we define them here, but the code is below)
void play(FatReader &dir);

//////////////////////////////////// SETUP
void setup() {
  Serial.begin(9600);           // set up Serial library at 9600 bps for debugging
  putstring_nl("\nWave test!");  // say we woke up!
  putstring("Free RAM: ");       // This can help with debugging, running out of RAM is bad
  // Set the output pins for the DAC control. This pins are defined in the library
  pinMode(2, OUTPUT);
  pinMode(3, OUTPUT);
  pinMode(4, OUTPUT);
  pinMode(5, OUTPUT);
  //  if (!card.init(true)) { //play with 4 MHz spi if 8MHz isn't working for you
  if (!card.init()) {         //play with 8 MHz spi (default faster!)
    error("Card init. failed!");  // Something went wrong, lets print out why
  // enable optimize read - some cards may timeout. Disable if you're having problems
  // Now we will look for a FAT partition!
  uint8_t part;
  for (part = 0; part < 5; part++) {   // we have up to 5 slots to look in
    if (vol.init(card, part))
      break;                           // we found one, lets bail
  if (part == 5) {                     // if we ended up not finding one  :(
    error("No valid FAT partition!");  // Something went wrong, lets print out why
  // Lets tell the user about what we found
  putstring("Using partition ");
  Serial.print(part, DEC);
  putstring(", type is FAT");
  Serial.println(vol.fatType(), DEC);     // FAT16 or FAT32?
  // Try to open the root directory
  if (!root.openRoot(vol)) {
    error("Can't open root dir!");      // Something went wrong,
  // Whew! We got past the tough parts.
  putstring_nl("Files found (* = fragmented):");

  // Print out all of the files in all the directories.

//////////////////////////////////// LOOP
void loop() {

/////////////////////////////////// HELPERS
* print error message and halt
void error_P(const char *str) {
  PgmPrint("Error: ");
* print error message and halt if SD I/O error, great for debugging!
void sdErrorCheck(void) {
  if (!card.errorCode()) return;
  PgmPrint("\r\nSD I/O error: ");
  Serial.print(card.errorCode(), HEX);
  PgmPrint(", ");
  Serial.println(card.errorData(), HEX);
* play recursively - possible stack overflow if subdirectories too nested
void play(FatReader &dir) {
  FatReader file;
  while (dir.readDir(dirBuf) > 0) {    // Read every file in the directory one at a time
    // Skip it if not a subdirectory and not a .WAV file
    if (!DIR_IS_SUBDIR(dirBuf)
         && strncmp_P((char *)&dirBuf.name[8], PSTR("WAV"), 3)) {

    Serial.println();            // clear out a new line
    for (uint8_t i = 0; i < dirLevel; i++) {
       Serial.write(' ');       // this is for prettyprinting, put spaces in front
    if (!file.open(vol, dirBuf)) {        // open the file in the directory
      error("file.open failed");          // something went wrong
    if (file.isDir()) {                   // check if we opened a new directory
      putstring("Subdir: ");
      dirLevel += 2;                      // add more spaces
      // play files in subdirectory
      play(file);                         // recursive!
      dirLevel -= 2;   
    else {
      // Aha! we found a file that isnt a directory
      putstring("Playing ");
      printEntryName(dirBuf);              // print it out
      wave.play();                       // make some noise!
        uint8_t n = 0;
        while (wave.isplaying) {// playing occurs in interrupts, so we print dots in realtime
          if (!(++n % 32))Serial.println();
        sdErrorCheck();                    // everything OK?
         if (wave.errors)Serial.println(wave.errors);     // wave decoding errors

I have attached the serial monitor output.
I'm not sure what I'm doing wrong... seems to load the files just fine, as well as trying to play them.

22:14:39.052 ->
22:14:39.052 -> Wave test!
22:14:39.052 -> Free RAM: 663
22:14:39.052 -> Using partition 1, type is FAT32
22:14:40.709 -> Wave test!
22:14:40.709 -> Free RAM: 663
22:14:40.742 -> Using partition 1, type is FAT32
22:14:40.776 -> Files found (* = fragmented):
22:14:40.809 -> ALLEMA~1.WAV
22:14:40.809 -> EEEYAA~1.WAV
22:14:40.842 -> NEVERG~1.WAV
22:14:40.842 -> h:⸮Q#

22:14:40.876 ->
22:14:40.876 -> Playing ALLEMA~1.WAV
22:14:41.142 -> ~1.WAV
22:14:41.142 -> NEVE3y⸮⸮, 0

Posts: 3
Joined: Sun Jan 17, 2021 3:22 pm

Please be positive and constructive with your questions and comments.