Arduino UNO + SD Card Module

Used Products:

1. Arduino UNO
2. SD Card Module

Code:

// sd card #include <SPI.h> #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."); writeLine("Salam Turkmenistan!"); } void loop() { } void writeLine(String text) { myFile = SD.open("data.txt", FILE_WRITE); if (myFile) { myFile.println(text); myFile.close(); } else { Serial.println("error opening test.txt"); } }