"SOLVED"Sd card connected properly but it still won't begin

hi i'm omar
so i'm making a project with a micro sd card and a speaker,i tried testing if the sd card module is working or not by testing the "cardinfo" example from the SD library,it sayed it's properly connected and all the information of the card was displayed properly.but when i tried the "files" example it said it is "failed to initialize sd card ".i'm using the kingston 32gb micro sd card.i'm dealing with the aruino uno board, i connected the MOSI TO 11,MISO TO 12,SCK TO 13 and CS TO 10.i inserted the sd card until it made a click noise so that means it is inserted well.i checked the wiring. this is the link for the micro sd card module i'm using:Micro SD Card Module For Arduino or MCU - Lampatronics. this is the code

#include <SD.h>
#include <TMRpcm.h>
#include <SPI.h>
TMRpcm pcm;
#define speaker 9
#define sdcard 10
void setup() {
  // put your setup code here, to run once:
  Serial.begin(9600);
SPI.begin();
if(!SD.begin(sdcard)){
Serial.println("memory is still the same");
return;
}
{
  Serial.println("memory increased");
}
pcm.speakerPin = speaker;
}

void loop() {
  // put your main code here, to run repeatedly:
pcm.play("my file");

delay(2000);
}

this an image for the connections. the wiring is a little bit tangled but i just couldn't untangle it for some reason:



Welcome to the forum

Please follow the advice given in the link below when posting code, in particular the section entitled 'Posting code and common code problems'

Use code tags (the < CODE/ > icon above the compose window) to make it easier to read and copy for examination

https://forum.arduino.cc/t/how-to-get-the-best-out-of-this-forum

1 Like

thanks,

You don't say how you formatted the card. In case you've not read it, this may help:

1 Like

oh yeah, i forgot to tell you but i did format several times on different apps including this one
!

The Files example opens the SD card with CS set to D4. Did you change that to 10? If CardInfo works, Files should also work.

1 Like

i did, i also tried the 10 ,8,and 4 for the cs pin and i tried to switch between the mosi and miso but still not working, thanks for all these people for replying

Did you format with the correct FAT32 file system?

Also try disconnecting the speaker, if you do not have a resistor in-line with the speaker you could be drawing a substantial amount of current.

1 Like

@ david_2018
Yep, I did everything you said. i'm starting to worry my micro sd module is broken!

If you can reproduce this test, then I would say that your SD card module is working.

Do you have another SD card you can try?

unfortunately,i don't have another one

How are you powering the SD module? Can you put a voltmeter on that VDD pin and see if there's any drop in voltage from 5V when you run the Files example? What happens when you press the reset button on the Uno after Files has failed?

i'm don't have a voltimeter,but i connected it to a 5v power supply so it should work?

it should work if you power the SD Card module via 5V pin of Arduino.
Please run the example code in this Arduino Micro SD Card tutorial, thencheck where the code can reach by checking the log on Serial Monitor.

i tried the code in the website it said this errorCompilation error: redefinition of 'SDLib::File myFile'
i don't know what it means or what should i do?

How many .ino file in the folder of your code ?

one?

It should be one.
The error you mentioned happens when there are two or more File myFile on your code. There are two cases:

  • You copy and paste code two time, or mixing between old code and new code.
  • Two .ino file in the same location

turns out i did copy the code more than 1 time,but it still says"SD CARD FAILED, OR NOT PRESENT!"

Have you tried different jumper wires? The wire can break inside the insulation and not be visibly bad.