Need a guru on this one :S

Hi, I’m not sure if this is the best section to ask this question, please let me know if there is a better section…

I’ve got an interesting issue with an alarm i’m trying to make. It’s using an arduino uno with a wave shield to play audio. Also hooked up to the Uno are two MAX7219 chips that are driving 2 8x8 LED matrix’s. I got the wave shield working fine, audio plays through my speakers just fine. I also have both LED matrix’s working perfectly. The only problem, they won’t work at the same time.

This is some example code I’m using below, look for the "*"s.

//#include <FatReader.h>
//#include <SdReader.h>
//#include <avr/pgmspace.h>
//#include "WaveUtil.h"
#include "WaveHC.h"
#include "LedControl.h"

SdReader card;    
FatVolume vol;    
FatReader root;   
FatReader f;      

WaveHC wave;

LedControl lc=LedControl(8,7,6);
LedControl lc2=LedControl(13,12,11);

void setup() {
  
  pinMode(2, OUTPUT);
  pinMode(3, OUTPUT);
  pinMode(4, OUTPUT);
  pinMode(5, OUTPUT);

//*********************************************************  
// the following 3 if statements is the code giving me issues. The only way to get the LED matrix's working is to comment out these three lines, and the only way to get the speaker working is to leave these lines how they are. 
if (!card.init()) {return;}
if (!vol.init(card)) {return;}
if (!root.openRoot(vol)) {return;}
//*********************************************************
  
  lc.shutdown(0,false);
  lc.setIntensity(0,8);
  lc.clearDisplay(0);
  lc2.shutdown(0,false);
  lc2.setIntensity(0,8);
  lc2.clearDisplay(0);
}


void loop() { 

playcomplete("hp1.WAV");

lc.setLed(0,2,3,true);
lc2.setLed(0,4,5,true);

}

void playcomplete(char *name) { 
if (wave.isplaying) {wave.stop();}
if (!f.open(root, name)) {return;}  
if (!wave.create(f)) {return;}   
wave.play();
while (wave.isplaying) { }}

If that code is absolutely necessary, is there another way to get the LED matrix’s working?

try it like this

//#include <FatReader.h>
//#include <SdReader.h>
//#include <avr/pgmspace.h>
//#include "WaveUtil.h"
#include "WaveHC.h"
#include "LedControl.h"

SdReader card;    
FatVolume vol;    
FatReader root;   
FatReader f;      

WaveHC wave;

LedControl lc=LedControl(8,7,6);
LedControl lc2=LedControl(13,12,11);

void setup() {
  
  pinMode(2, OUTPUT);
  pinMode(3, OUTPUT);
  pinMode(4, OUTPUT);
  pinMode(5, OUTPUT);

//*********************************************************  
// the following 3 if statements is the code giving me issues. The only way to get the LED matrix's working is to comment out these three lines, and the only way to get the speaker working is to leave these lines how they are. 
if (!card.init()) {return;}
if (!vol.init(card)) {return;}
if (!root.openRoot(vol)) {return;}
//*********************************************************
  
  lc.shutdown(0,false);
  lc.setIntensity(0,8);
  lc.clearDisplay(0);
  lc2.shutdown(0,false);
  lc2.setIntensity(0,8);
  lc2.clearDisplay(0);
}


void loop() { 
if (!wave.isplaying) 
  playcomplete("hp1.WAV");

lc.setLed(0,2,3,true);
lc2.setLed(0,4,5,true);

}

void playcomplete(char *name) { 
if (wave.isplaying) {wave.stop();}
if (!f.open(root, name)) {return;}  
if (!wave.create(f)) {return;}   
wave.play();
}

Nope, the LED matrix isn't working still but the audio works fine.

But you got rid of the while (wave.isplaying) { } near the end of the sketch? AND actually uploaded (not just verified)?

Yes, I copied and pasted your code.