Back with another likely simple fix that I've been struggling with for hours.
Description: I have an Inland Pro Mico and Adafruit Adalogger, links below.
In the screen shot below you will see my current setup. Im not worried about the RTC on the board.
I understand the Pro Micro pinout to be
SD card attached to SPI bus as follows:
** MOSI - pin 16
** MISO - pin 14
** CLK - pin 15
** CS - pin 10? I've also tried pin 3
My output from the code below is always: Initializing SD card...initialization failed!
Thank you for any guidance.
Code:
#include <SPI.h>
#include <SD.h>
File root;
void setup() {
// Open serial communications and wait for port to open:
Serial.begin(9600);
while (!Serial) {
; // wait for serial port to connect. Needed for native USB port only
}
Serial.print("Initializing SD card...");
if (!SD.begin(10)) {
Serial.println("initialization failed!");
while (1);
}
Serial.println("initialization done.");
root = SD.open("/");
printDirectory(root, 0);
Serial.println("done!");
}
void loop() {
// nothing happens after setup finishes.
}
void printDirectory(File dir, int numTabs) {
while (true) {
File entry = dir.openNextFile();
if (! entry) {
// no more files
break;
}
for (uint8_t i = 0; i < numTabs; i++) {
Serial.print('\t');
}
Serial.print(entry.name());
if (entry.isDirectory()) {
Serial.println("/");
printDirectory(entry, numTabs + 1);
} else {
// files have sizes, directories do not
Serial.print("\t\t");
Serial.println(entry.size(), DEC);
}
entry.close();
}
}
connecting a mini SD card reader to a Pro micro (3.3V 8MHz) so
// Pro Micro (3.3V 8 MHz version) connections
// Pro Micro SCK pin 15 to SD card SCK
// Pro Micro MISO pin 14 to SD card MISO
// Pro Micro MOSI pin 16 to SD card MOSI
// Pro Micro pin 10 to SD card CS
// Pro Micro pin GND to SD card GND
// Pro Micro pin VCC to SD card 3V3
and running your code of post 1 the serial monitor displays
I appreciate your confirmation. I have tried 3 SD cards of various size and brand new. I may have a damaged SD board. I have other SPI devices working so ill have to investigate further it seems.