SD library won't read card unless I remove card reset then reinsert card

Subject pretty much sums it up. As long as I remove the sd card and then reset the arduino it reads the sd fine. If I reset with the card in it will not read. This is the guts of a kids stuffed animal music player so it can’t be finicky like this. (was supposed to be a Christmas present, oops) I’m using an arduino mega and this cheapy sd module:
Btw if you aren’t aware of check it out. Insanely cheap and really fast shipping despite being in china.

Here’s 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 53  //using digital pin 4 on arduino nano 328, can use other pins
#include <TMRpcm.h>           //  also need to include this library...
#include <SPI.h>

TMRpcm tmrpcm;   // create an object for use in this sketch

unsigned long time = 0;

void setup() {

  tmrpcm.speakerPin = 5; //5,6,11 or 46 on Mega, 9 on Uno, Nano, etc
  //Complimentary Output or Dual Speakers:
  //pinMode(10,OUTPUT); Pin pairs: 9,10 Mega: 5-2,6-7,11-12,46-45

  pinMode(13, OUTPUT); //LED Connected to analog pin 0
  pinMode(10, OUTPUT);
  digitalWrite(10, HIGH);
  pinMode(53, OUTPUT);
  digitalWrite(53, HIGH);
  pinMode(4, OUTPUT);
  digitalWrite(4, HIGH);
  while (!SD.begin(SD_ChipSelectPin)) {  // see if the card is present and can be initialized:
    Serial.println("SD fail");
    digitalWrite(53, LOW);
    digitalWrite(53, HIGH);
  }"music"); //the sound file "music" will play each time the arduino powers up, or is reset

void loop() {

  //blink the LED manually to demonstrate music playback is independant of main loop
  if (tmrpcm.isPlaying() && millis() - time > 50 ) {
    digitalWrite(13, !digitalRead(13));
    time = millis();
  else if (millis() - time > 500) {
    digitalWrite(13, !digitalRead(13));
    time = millis();

  if (Serial.available()) {
    switch ( {
      case 'd':"music");
      case 'P':"temple");
      case 't':"catfish");
      case 'p':
      case '?':
        if (tmrpcm.isPlaying()) {
          Serial.println("A wav file is being played");
      case 'S':
      case '=':
      case '-':
      case '0':
      case '1':


Thanks for your help!

Your SD module looks like either the LC Studio SD module or a copy. This module is known to have lots of problems, search the forum for the many posts.

Here is how it can be fixed but it would be better to buy a module with level shifters to convert the Arduino 5 V signals to 3.3 V.

Some SD cards work with this module but only because they have good input protection circuits that draw so much current that the Arduino is not able to drive the SPI to 5 V. Not good for the card or Arduino.

Ah I see, thanks for the reply and info. This thing is way over what I budgeted so I was trying to cut costs. On a related note does this look like a level shifter on this one? I don't see any resistors.

The 8-pin smd with 103 looks like a resistor pack of 10k pullups.

Here is a shield that works on Mega or Uno.

This module has level shifters but early versions have a problem sharing the SPI bus with other devices, the MISO line is not released by a level shifter on MISO. If you only use the SPI for an SD card, this works fine.

Awesome thanks! I just bit the bullet and bought this one. 5 bucks I didn’t really have but this Christmas present is really late already.
There won’t be any other spi devices so none of that should be a problem. Shame to sacrifice an entire mega for 1 spi and 6 or 7 inputs but oh well, that’s what I have laying around.

I really appreciate all the help.

I'm getting the same problem on an Ethernet Shield V2 (which is an official Arduino product and shouldn't have this type of problem in the first place).