Go Down

Topic: Create file and printDirectory on cycle. (Read 1 time) previous topic - next topic


Hi, i have problem with function in cycle. This is my code:

Code: [Select]
#include <SD.h>

File root;

const int chipSelect = 4;   

void setup()

  pinMode(10, OUTPUT);
  if (!SD.begin(4)) {
    Serial.println("Failed to configure SD card");

void loop()
  delay (3000);
  delay (3000);

void printDirectory() {
  root = SD.open("/");
  while(true) {
     File entry =  root.openNextFile();
     if (! entry) {


void createfile(char *myfile)
  Serial.println("file creating...");
  if (SD.exists(myfile)) {
    Serial.println("but exist.");
  else {
    root = SD.open(myfile, FILE_WRITE);

So, when im start procces after reset, only first printDirectory on loop show file list on sd root corectly. After that i use createfile like second function on loop, then third printDirectory cant show file list. And after that all printDirectory cant show file list. In this case help only reset button. Can you help mi someone with this ? Thanks


There seems to be a lot of bugs in the Arduino 1.0 version of SD.h.  The listfiles example seems to have problems.  People also have reported problems with the Datalogger example.

Lots of people contact me since I wrote SdFat and SD.h is a wrapper for an old version of SdFat.

I had nothing to do with the SD.h wrapper and no longer support the version of SdFat that was use for SD.h.

Go Up

Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

via Egeo 16
Torino, 10131