tmrpcm - abnormal problem

Since i used "tmrpcm" library i have problem.

No sound

i am using check statement to know if the problem with the connections or other

 Serial.println("Not Playing");

it replies "Not Playing" till i connected pin-10 to the ground

then it replied Playing" and the sound played for 1 or 2 seconds then loud buzzer run and the Serial became unreasonable

after that i put 100ohm resistor between pin-10 and ground , the problem solved for some times , but without any change it hang again. :\

now it back to the loud buzzer after the sound run :(

How can i fix that? is that error on library or what?

you need to tell more - post the whole code - post a link to the library (I do not know it and I am not googling for it as I may find another version) - post your schema of what you connected and how

Then we have a chance we can spot the cause.

Library Link:

Default SD-card wiring —> in pins (4 , 11 , 12 , 13) + pin-10 which i connected to gnd with 100ohm recently

Speaker from “pin-9” to “gnd”

Whole Code:

#include <SD.h>                      // need to include the SD library
#define SD_ChipSelectPin 4  //using digital pin 4 on arduino nano 328
#include <TMRpcm.h>           //  also need to include this library...
 String inByte;
TMRpcm tmrpcm;   // create an object for use in this sketch
int lastpstat = 0;

void setup(){

  tmrpcm.speakerPin = 9; //11 on Mega, 9 on Uno, Nano, etc
  if (!SD.begin(SD_ChipSelectPin)) {  // see if the card is present and can be initialized:
  Serial.println("No SD!");
  return;   // don't do anything more if not
   Serial.println("SD Card is Ready."); 
 tmrpcm.volume(1);"2.wav",0); //the sound file "1" will play each time the arduino powers up, or is reset

void loop(){  
   // if (SD.begin(SD_ChipSelectPin)) {  // see if the card is present and can be initialized:

 // return;   // don't do anything more if not

if (Serial.available() > 0) {
    // get incoming byte:
    inByte = Serial.readString();
   if (inByte == "1"){
  Serial.println("Playing 1.wave ....");
   else if (inByte == "2"){
 Serial.println("Playing 2.wave ....");} 
   else if (inByte == "3"){tmrpcm.stopPlayback();"3.wav",0);
 Serial.println("Playing 3.wave ....");} 
    else if (inByte == "1"){tmrpcm.stopPlayback();"1.wav",0);
 Serial.println("Playing 1.wave ....");} 
    else if (inByte == "volup"){tmrpcm.volume(1);
 Serial.println("VOL Is increased....");} 
   else if (inByte == "voldown"){tmrpcm.volume(0);
 Serial.println("VOL Is decreased....");} 


 Serial.println("Playing ....");



//    }  

What kind of board are you running this on?

I'm not really sure on this, but a couple things you could try: 1. Connect the 100Ohm resistor between the speaker and pin9. SD cards can draw quite a bit of power, so this may help with the issue if the speaker is drawing too much power. 2. Open the pcmConfig.h file included with the library and uncomment the line: #define DISABLE_SPEAKER2 just in case there is something weird going on with pin 10. I don't understand why connecting a resistor would change things. 3. Reformat the SD card and reload the wav files, they can get corrupted easily when running on breadboards sometimes. I like to double-up on connecting wires where possible when using SD cards on breadboards as well.