Buzzing Sound From Speaker

Hi,

I am a newbie and doing a school project to learn more on Arduino.

I have Arduino Uno and ethernet shield. I have connected these two and also have put a formatted micro SD card in the SD card reader of the ethernet shield. I have connected a basic speaker from a local hobby shop on pin 9 and ground.

When I try to run a program at http://www.arduino.cc/en/Tutorial/Tone, it works perfectly fine. The only minor change is that I have used pin 9 instead of pin 8, and this tutorial works perfectly fine for me.

My next goal is to play a simple audio file.

For this, I am trying to use TMRpcm, the same circuit and sample programs giving me buzzing sound on my output. Here is my code, but I believe the issue may be with my circuit itself:

#include <SD.h>
#define SD_ChipSelectPin 4
#include <TMRpcm.h>

TMRpcm tmrpcm;
char mychar;

void setup(){

tmrpcm.speakerPin = 9;

Serial.begin(9600);
if (!SD.begin(SD_ChipSelectPin)) { // see if the card is present and can be initialized:
Serial.println("SD fail");
return; // don't do anything more if not
Serial.println("SD successful");
}
tmrpcm.setVolume(7);
tmrpcm.quality(1);

tmrpcm.play("DRUM1.WAV");

}

void loop() {
Serial.print("In loop"); // This is just a dummy code
delay(5000);

}

Can someone help with point me to right circuit for this, or point me to a simple audio file player?

Thanks.

What speaker are you using and how is it connected to pin 9 of your UNO?
An arduino pin is not really capable of driving speakers without an amplifier though ear buds and very small speakers will sort of work.

I am using some basic speaker that i bought from store, something that costed me about a dollar and is about 2.5 inch diameter. I am connecting one end of the speaker directly to pin 9 and other end of the speaker to ground.

I am realizing from your reply that i may have to connect using an amplifier. I did some more search on this. Do I have to use something like http://www.amazon.com/gp/product/B00RECZC7I?

Thanks.

. Do I have to use something like http://www.amazon.com/gp/product/B00RECZC7I?

No that is an input amplifier, you want an output amplifier.

Any example of output amplifier?

https://www.coolcomponents.co.uk/stereo-20w-class-d-audio-amplifier-max9744.html?gclid=CjwKEAiAluG1BRDrvsqCtYWk81gSJACZ2BCe1aUPOde8kQCKLbH5EJi8qtlF-7HfQwRa2K6ZhRN5_RoC6N3w_wcB