📜 ⬆️ ⬇️

Homemade SD Card Shield for Arduino

Greetings,% username%!
I thought the other day that for my future, 2 nuclear copter (and there are few other projects) it would be nice to make a black box ( GPS ), and for this you need a lot of memory and EEPROM does not help, and therefore you should buy or make an SD shield for arduino.
It is expensive to buy for such trifles and wait for a long time while they send it, so we google and find that the people rivet their shields, for this we need only 6 resistors, an adapter / connector for the memory card and the card itself (it worked with SD and SDHC cards formatted in FAT16 and FAT32).

The scheme is quite simple ( read more here ):

resistors are needed to reduce the voltage from 5 to about 3.4 volts
soldered, it turned out this beauty:

I took the code from standard examples of Arduino, only slightly corrected pins for the variant of the scheme (the changed places are marked in bold, at the same time translated into Russian in some places):
/* SD card read/write              SD    * SD    SPI : ** MOSI - pin 11 ** MISO - pin 12 ** CLK - pin 13 ** CS - pin 10   2010 David A. Mellis  2  2010 Tom Igoe     2011 Gleb Devyatkin    -  . */ #include <SD.h> File myFile; void setup() {   Serial.begin(9600);   Serial.print("Initializing SD card...");   // On the Ethernet Shield, CS is pin 4. It's set as an output by default.   // Note that even if it's not used as the CS pin, the hardware SS pin   // (10 on most Arduino boards, 53 on the Mega) must be left as an output   // or the SD library functions will not work.   pinMode(10, OUTPUT);   if (!SD.begin(10)) {     Serial.println("initialization failed!");     return;   }   Serial.println("initialization done.");   //  . ,         ,   //     ,   .   myFile = SD.open("test.txt", FILE_WRITE);   //    ,   :   if (myFile) {     Serial.print("Writing to test.txt...");     myFile.println("testing 1, 2, 3.");     //  :     myFile.close();     Serial.println("done.");   } else {     //     ,     :     Serial.println("error opening test.txt");   }   //   ,  :   myFile = SD.open("test.txt");   if (myFile) {     Serial.println("test.txt:");     //   ,     :     while (myFile.available()) {       Serial.write(myFile.read());     }     //  :     myFile.close();   } else {     //    ,    :     Serial.println("error opening test.txt");   } } void loop() {   //   ,        } 


The field of testing this code - on your card there will be a TEST.TXT file with the contents of "testing 1, 2, 3." (or many times this line if the code was run more than once, which is a little strange, since FILE_WRITE should have overwritten the file)

')

Source: https://habr.com/ru/post/115176/


All Articles