Struggling Playing WAV File on Arduino Uno


I’m new to using Arduino, and I’m working on a project that requires that I play a wav file from an SD Card using an 8-ohm speaker. I first tried the “toneMultiple” example which worked fine, as I was able to play the tones fine (I modified the code to play the tones successively on the same speaker), but when I try to play wav files from the SD card, all I hear is static from the speaker.

Any ideas as to what could be wrong? (I attached my code for playing wav files from the speaker.)

Speaker-Sketch.ino (737 Bytes)

Connect the speaker with a large capacitor not directly. About 100uF should do it.