Uno R3 issues with SD card read

This subject seems to be pretty popular but I cannot seem to find an answer to my issue. I am hoping someone can assist. I am new to Arduino and just got an Uno R3 and I am trying to play a .wav song from an SD card through an 4ohm 3 watt speaker. I have ran the Cardinfo sketch example in IDE and the SD card is being recognized and read but when I run try to run the sketch to play the song I get an "SD fail" message. I have included the code, the Cardinfo script, type of SD card module I have, and an attempt to show wiring (with Tinkercad) which I could not find an animation for the SD card so I just showed wiring.

#include "SD.h"
#define SD_ChipSelectPin 10
#include "TMRpcm.h"
#include "SPI.h"
TMRpcm tmrpcm;

void setup() 
{
  
tmrpcm.speakerPin=9;
Serial.begin(9600);
if(SD.begin(SD_ChipSelectPin)) 
{
  Serial.println("SD fail");
  return;
}
tmrpcm.setVolume(5);
tmrpcm.play("jugg.wav");

}

void loop() {
  

}

IDE cardinfo+error


Please help. I have reviewed quite a few forums and dove into YouTube and I am still unable to find a solution. Thank you!

You need a resistor to limit the current to the transistor base, otherwise you can damage the Arduino pin.

Have you considered getting a DFPlayer Mini? Much easier and way better results.

A resistor for the speaker transistor? Would that affect the SD card read?
I will look into the DFPlayer Mini. Thanks

What you have in your sketch:

if(SD.begin(SD_ChipSelectPin)) 

What you need to make it work:

if(!SD.begin(SD_ChipSelectPin))
// ^

Thank you Van_der_decken! That worked perfectly!

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.