Ardunio Mega Sd Card initialization failed | SPI protocol

Hello, I am trying to build a flight data recorder for my airplane using an SD card module and Arduino Mega but I am getting the error initialization failed!

I couldn't find the name of the module but here is where I bought it:

This module has level shifter on board so it is tolerant to 5V ardunio boards.

I used the following sketch:

I triple checked the wiring and here it is:

MOSI => 51, MISO => 50, SCK => 52 , SS => 53

I tried using the module on Ardunio UNO and it worked great.

I checked if the cables or ardunio pins are faulty using a multimeter. They worked great. Ardunio SPI pins are connected to atmega chip (checked).

I am not sure if I am doing something wrong. All input is appriciated

SOLVED! Guys even though it says initialization failed it actually is not failing. I dont understand why but when you change the part

Serial.print("Initializing SD card...");
if (!SD.begin(10)) {
Serial.println("initialization failed!");
while (1);
Serial.println("initialization done.");



it starts to work marvelously !!

But It would be still helpful if someone can explain why did it say failed in the first place

SD.begin(10) means use pin 10 for the SS on the SD card.

SD.begin() means use the default pin which is 53 on a Mega.

Well, it explains everything. Thanks