Hey guys,
I'm a complete novice when it comes to designing circuits and stuff. I have a bcakground in computer science, with years of Java but no clue when it comes to electrical engineering. That being said, I am creating a project with my UNO in which I trigger switches to play corresponding .wav files. I have an SEEEDstudio SD card shield from RadioShack, and I have connected my 9th digital out to a 220 Ohm resistor, which is in turn hooked up to a 2N4401 transistor with 5v in on one side and out to my 8Ohm (.3W) speaker on the other, which is in turn grounded. My wav files play perfectly, albeit a bit on the quiet side, however as they play, there is a constant high pitched tone playing along with the music. Do you guys have any idea what I'm doing wrong? Or is this an un-fixable Arduino thing?
Here is my code:
#include <SD.h> // need to include the SD library
//#define SD_ChipSelectPin 53 //example uses hardware SS pin 53 on Mega2560
#define SD_ChipSelectPin 10 //using digital pin 4 on arduino nano 328
#include <TMRpcm.h> // also need to include this library...
TMRpcm tmrpcm; // create an object for use in this sketch
char mychar;
const int sw = 3;
int swst = 0;
void setup(){
tmrpcm.speakerPin = 9; //11 on Mega, 9 on Uno, Nano, etc
pinMode(3, INPUT);
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
}
tmrpcm.play("Wish.wav"); //the sound file "wish" will play each time the arduino powers up, or is reset
}
void loop(){
}
The loop method is empty because I was first just trying to get the sound output right.