GND to GND
VCC to 5v
MISO TO 50
MOSI TO 51
SCK TO 52
CS TO 53
Program used
#include <SPI.h>
#include <SD.h>
const int chipSelect = 53; // Ensure this matches your CS pin connection
void setup() {
Serial.begin(9600);
pinMode(53, OUTPUT); // For the Mega, ensure pin 53 is set to OUTPUT
digitalWrite(53, HIGH); // Ensure this pin is not interfering with SPI communication
Serial.print("Initializing SD card...");
if (!SD.begin(chipSelect)) {
Serial.println("initialization failed!");
return;
}
Serial.println("initialization done.");
}
void loop() {
// Nothing in loop for basic initialization check
}
INITIALISATION FAILED!!
same program, sd card, and sd card reader I connected to a uno, it is working... but not working on mega,
tried changing the jumper wires, still not working.
i also tried with a different mega board, still not working
I found D53 doesn't work as a CS for remote devices. D53 determine whether the SPI is a master or slave.
Connect SD CS to pin 4. Then use this code:
#include <SPI.h>
#include <SD.h>
const int chipSelect = 4; // Ensure this matches your CS pin connection
void setup() {
Serial.begin(9600);
pinMode(chipSelect, OUTPUT); // For the Mega, ensure pin 53 is set to OUTPUT
digitalWrite(chipSelect, HIGH); // Ensure this pin is not interfering with SPI communication
Serial.print("Initializing SD card...");
if (!SD.begin(chipSelect)) {
Serial.println("initialization failed!");
return;
}
Serial.println("initialization done.");
}
void loop() {
// Nothing in loop for basi
@aaron_eipe_123
The big (8gig) SD cards can draw a lot of current. Do you have a smaller capacity card you could try?
Also, do you have the card power connected to the 5V output pin on the Mega?
Do you have anything else on the SPI bus?
@ jim, the issue is 8GB is the smallest SD card available locally as well as online
@ yes card VCC to 5V
@ i was troubleshooting with only the SD module connected to the Mega board. so NO, i didn't have anything else on the SPI bus
They are, but were they actually connected like that?
Edit: I'm currently testing a TFT display with SD. It is connected as the OP described, and it works.
Edit2: I got tired of dealing with this, so I ordered a proto shield with an ICSP connector. I plan on clipping off pins 11-13 on the shield and rewiring the ICSP pins to those.
I'll plug the shield into the Mega, and the Uno-type SD shield onto it. Done.
Is it not possible to use your multimeter to find what module pins the ICSP pins are connected to? For future reference, I'd like to know that if it's different from the original connections.
GND to GND
VCC to 5v
MISO TO 50
MOSI TO 51
SCK TO 52
CS TO 53
i tried cs to 4, 8 & 10, each time making changes in the program.
i pulled out all the jumpers and rewired multiple times to make sure the wiring is as mentioned in post #1