I want to use the SD card slot on my ''RepRapDiscount Full Graphic Smart controller'' to read and write data to and from it to my SD card.
My question lays in the connection. I have connected the adapter and my arduino due as shown below (CONN1*), but the SD test program says it can't initialize the SD card. I think that i did something wrong in the connection between the "smart adapter"(S1*) and the arduino. in the SD test program it says i have to connect it as shown below(CONN2*), but those are not the SPI pins for ardriuno due. I have found some potential correct connections while looking on the internet, but i am not sure if they are correct and i could not find the correct connection for "SD DET".
Also where can i change the connection pins in the SD test program? I can't find the pins in the code it self. It seems like the default pins are for the Arduino UNO.
CONN1:
SMART Adaptor Arduino due
N/C -
SD CSEL Pin 4
MOSI Pin 109 (MOSI)
SD DET - (Could not find connection)
GND GND
SCK Pin 110 (SCK)
MISO Pin 108 (MISO)
VCC 3.3V
CONN2:
SD CARD Arduino Pin
MOSI - Pin 11
MISO - Pin 12
CLK - Pin 13
CS - Pin 4
SD card code:
/*
SD card read/write
This example shows how to read and write data to and from an SD card file
The circuit:
* SD card attached to SPI bus as follows:
** MOSI - pin 11
** MISO - pin 12
** CLK - pin 13
** CS - pin 4 (for MKRZero SD: SDCARD_SS_PIN)
created Nov 2010
by David A. Mellis
modified 9 Apr 2012
by Tom Igoe
This example code is in the public domain.
*/
#include <SPI.h>
#include <SD.h>
File myFile;
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(4)) {
Serial.println("initialization failed!");
while (1);
}
Serial.println("initialization done.");
// open the file. note that only one file can be open at a time,
// so you have to close this one before opening another.
myFile = SD.open("test.txt", FILE_WRITE);
// if the file opened okay, write to it:
if (myFile) {
Serial.print("Writing to test.txt...");
myFile.println("testing 1, 2, 3.");
// close the file:
myFile.close();
Serial.println("done.");
} else {
// if the file didn't open, print an error:
Serial.println("error opening test.txt");
}
// re-open the file for reading:
myFile = SD.open("test.txt");
if (myFile) {
Serial.println("test.txt:");
// read from the file until there's nothing else in it:
while (myFile.available()) {
Serial.write(myFile.read());
}
// close the file:
myFile.close();
} else {
// if the file didn't open, print an error:
Serial.println("error opening test.txt");
}
}
void loop() {
// nothing happens after setup
}
S1:
S2: