Sd Card Reader Not Connecting

Hey Everyone,

Im new to coding, so I apologise if this is posted on the wrong forum.

I am trying to create a simple audio player for a school project and followed this tutorial.

When ever I press the reset button on my Arduino uno a message shows up in my serial monitor saying "SD fail" and no audio plays, I understand that this message is written into the code incase of an error.

My code is as follows,

#include "SD.h"
#define SD_ChipSelectPin 4
#include "TMRpcm.h"
#include "SPI.h"

TMRpcm tmrpcm;

void setup(){
tmrpcm.speakerPin = 8;
Serial.begin(9600);
if (!SD.begin(SD_ChipSelectPin)) {
Serial.println("SD fail");
return;
}

tmrpcm.setVolume(6);
tmrpcm.play("nine.wav");
}

void loop(){  }

Any Help Would be greatly Appreciated,

Thanks :slight_smile:

Welcome to the forum

How is the SD card module connected to the Uno ?

MOSI - pin 11
MISO - pin 12
SCK - pin 13
CS - Pin 4
VCC - 5V

and GND ?

to GND

It sounds OK

Have you tried the SD card ReadrWrite example in the IDE ?

If you're using arduino UNO, then you have to configure pin#10 as the chip select pin. Also you'll have to make your hardware connection accordingly.

Pin 10 needs to stay as an output.

But the SD library should accept other output pins as the chip select pin.

Which type of SD card module do you have? Is it a simple board with just the SD card holder and a pin header, or does it have additional electronics on it?

For an UNO, it should look something like this one:


Not like this one:

Really ?

The examples with the SD library use pin 4 and they certainly work with a Uno

Pin#4 should be used when you use an Ethernet shield. For direct connection with UNO, pin#10 must be used. At least that is what I have seen when working with UNO and SD card storage board. PIn#10 is the SS pin.

If you see the cardinfo example of the arduino IDE, you'll find the following comments:
// change this to match your SD shield or module;
// Arduino Ethernet shield: pin 4
// Adafruit SD shields and modules: pin 10
// Sparkfun SD shield: pin 8
// MKRZero SD: SDCARD_SS_PIN

The example might well make suggestions, for particular bits of hardware.

However, where does it say that you must only use pin 10 for an SD card chip select on a UNO ?

When using a stand alone module rather than a shield the SS pin is up to you to decide

i’m using the blue one

That's a good start. Next, have you tried the SD library examples that @UKHeliBob suggested back in post #6.

As I asked previously

thanks i tried it and have managed to get it to work

Can you help the forum by publishing what you did to solve your prolem ?

My code and wiring was all ok, the issue is I hadn't properly formated my Sd card