Hi, ich bin neu in der Arduino-Welt und versuche ein SD-Kartenmodul mit meinem Arduino DUE anzusteuern. Ich habe diesen Guide hier gefunden:
Ich weiß, in dem Guide geht es um einen Arduino MEGA und keinen DUE. In den Comments lässt sich jedoch folgender Kommentar finden:
"""
Hi!
Great tutorial! I was a little problem, but I solved it. My DUE’s pins allocation not the same as the Mega’s. Here is the connecting:
CS-> pin 10
GND->GND
MISO,MOSI,SCK->SPI for SAM3X8E (center of the board)
Thanks,
Z.
"""
Dies versuche ich gerade zu bewerkstelligen, allerdings bin ich mir nicht sicher, wie ich die SPI Pins einstecken muss. Könnte mir jemand helfen? (Ich habe den CS-Pin im code von 53 zu 10 geändert)
Ich habe das Selbe SD-Modul wie im Guide.
Hier der Code aus dem Guide zum Testen, ob die SD-Karte angesteuert werden kann:
/*
* Arduino SD Card Tutorial Example
*
* by Dejan Nedelkovski, www.HowToMechatronics.com
*/
#include <SD.h>
#include <SPI.h>
File myFile;
int pinCS = 10; // Pin 10 on Arduino Uno
void setup() {
Serial.begin(9600);
pinMode(pinCS, OUTPUT);
// SD Card Initialization
if (SD.begin())
{
Serial.println("SD card is ready to use.");
} else
{
Serial.println("SD card initialization failed");
return;
}
// Create/Open file
myFile = SD.open("test.txt", FILE_WRITE);
// if the file opened okay, write to it:
if (myFile) {
Serial.println("Writing to file...");
// Write to file
myFile.println("Testing text 1, 2 ,3...");
myFile.close(); // close the file
Serial.println("Done.");
}
// if the file didn't open, print an error:
else {
Serial.println("error opening test.txt");
}
// Reading the file
myFile = SD.open("test.txt");
if (myFile) {
Serial.println("Read:");
// Reading the whole file
while (myFile.available()) {
Serial.write(myFile.read());
}
myFile.close();
}
else {
Serial.println("error opening test.txt");
}
}
void loop() {
// empty
}