Hallo Zusammen,
auch wenn es über dieses Thema schon mehrere Topics gibt, bin ich trotz
mehrstündiger Suche zu keiner Lösung gekommen.
Mein Problem ist, dass ich meinen Arduino 2560 Mega mit einer SD-Karte
verbinden möchte. Hierzu habe ich folgenden Aufbau verwendet:
http://www.comm2excel.com/projects/pics/sd_card_module.png
Ich verwende eine 4 GB Elite Pro Memory Card (FAT 32).
Verwende ich folgendes Beispielprogramm und hab hierzu eine test.txt auf
der SD Karte Erstellt.
1 | /*
|
2 | SD card read/write
|
3 |
|
4 | This example shows how to read and write data to and from an SD card file
|
5 | The circuit:
|
6 | * SD card attached to SPI bus as follows:
|
7 | ** MOSI - pin 11
|
8 | ** MISO - pin 12
|
9 | ** CLK - pin 13
|
10 | ** CS - pin 4
|
11 |
|
12 | created Nov 2010
|
13 | by David A. Mellis
|
14 | modified 9 Apr 2012
|
15 | by Tom Igoe
|
16 |
|
17 | This example code is in the public domain.
|
18 |
|
19 | */
|
20 |
|
21 | #include <SPI.h>
|
22 | #include <SD.h>
|
23 |
|
24 | File myFile;
|
25 |
|
26 | void setup()
|
27 | {
|
28 | // Open serial communications and wait for port to open:
|
29 | Serial.begin(9600);
|
30 | while (!Serial) {
|
31 | ; // wait for serial port to connect. Needed for Leonardo only
|
32 | }
|
33 |
|
34 |
|
35 | Serial.print("Initializing SD card...");
|
36 |
|
37 | if (!SD.begin(53)) {
|
38 | Serial.println("initialization failed!");
|
39 | return;
|
40 | }
|
41 | Serial.println("initialization done.");
|
42 |
|
43 | // open the file. note that only one file can be open at a time,
|
44 | // so you have to close this one before opening another.
|
45 | myFile = SD.open("test.txt", FILE_WRITE);
|
46 |
|
47 | // if the file opened okay, write to it:
|
48 | if (myFile) {
|
49 | Serial.print("Writing to test.txt...");
|
50 | myFile.println("testing 1, 2, 3.");
|
51 | // close the file:
|
52 | myFile.close();
|
53 | Serial.println("done.");
|
54 | } else {
|
55 | // if the file didn't open, print an error:
|
56 | Serial.println("error opening test.txt");
|
57 | }
|
58 |
|
59 | // re-open the file for reading:
|
60 | myFile = SD.open("test.txt");
|
61 | if (myFile) {
|
62 | Serial.println("test.txt:");
|
63 |
|
64 | // read from the file until there's nothing else in it:
|
65 | while (myFile.available()) {
|
66 | Serial.write(myFile.read());
|
67 | }
|
68 | // close the file:
|
69 | myFile.close();
|
70 | } else {
|
71 | // if the file didn't open, print an error:
|
72 | Serial.println("error opening test.txt");
|
73 | }
|
74 | }
|
75 |
|
76 | void loop()
|
77 | {
|
78 | // nothing happens after setup
|
79 | }
|
Mein Problem ist, dass ich in die Initialiserung der SD-Karte nicht
funktioniert. Hierzu wird im "Serieller Monitor" folgendes angezeigt:
1 | "Initializing SD card...initialization failed!"
|
Das heißt, dass ich schon beim initialieren Probleme habe.
Da ich Anfänger in der MC-Programmierung bin, hoffe ich, dass ihr mir
weiter helfen könnt. Vielen Dank!