Go Down

Topic: SD Card Initialization failed during data logger interface with Arduino Uno (Read 557 times) previous topic - next topic

Suvendu_dash

I want to store the analog data in the sd card but i find out this Initialization failed message. Plz give some solutions in this regards.

Code: [Select]

#include<SD.h>
#include <SPI.h>

#define SD_ChipSelectPin 10 
File myFile;
int LDRPin = A0;
int val=0;

void setup() {
 
pinMode(LDRPin, INPUT);
Serial.begin(9600);
Serial.println("Initialising SD card...");
if(!SD.begin(SD_ChipSelectPin))
{
  Serial.println("Initialization failed");
  return;
}
  Serial.println("Initialization success");
 
}

void loop() {

val=analogRead(LDRPin);
myFile=SD.open("test.txt", FILE_WRITE);
if(myFile)
{
  myFile.print(val);
  Serial.print(val);
  myFile.print(",");
  Serial.print(",");
  myFile.println(millis());
  Serial.println(millis());
  myFile.close();
}
else
{
  Serial.println("Error in opening file");
}
delay(1000);
}



Go Up