I need to write and read some data from SD card. I link SD card(LC STUDIO) to Arduino (UNO). I use this link for create my project. In first day I don't have any problem and data correctly save to file. But now my circuit isn't work nicely. When Arduino is running the sketch I don't saw any error message.But when I link the SD card to my laptop, I don't saw any file on card!! The code is here:
#include <SPI.h>
#include <SD.h>
const int chipSelect = 10;
File file;
void setup()
{
Serial.begin(9600);
while (!Serial) {
;
}
Serial.print("Initializing SD card...");
pinMode(10, OUTPUT);
if (!SD.begin(chipSelect)) {
Serial.println("Card failed, or not present");
}
Serial.println("card initialized.");
//creating file
file = SD.open("test.txt",FILE_WRITE);
file.close();
//write data to file
file = SD.open("test.txt",FILE_WRITE);
if(file){
file.println("OK!!");
file.println("1");
file.println("2");
file.println("3");
file.println("OK!!");
file.close();
}
}
void loop()
{
}