Show Posts
Pages: 1 ... 11 12 [13]
181  Using Arduino / Storage / Re: SD CARD Create File and then Read Directory Problem on: November 13, 2012, 12:50:49 am
Use this to locate files and try to remove stuff which you don't need

Code:
File dataFile;
Sd2Card card;
SdVolume volume;
SdFile root;

void setup()
{
  // Open serial communications and wait for port to open:
  Serial.begin(115200);
  pinMode(10, OUTPUT);
 
  if (!card.init(SPI_HALF_SPEED, 4)) {
    Serial.println("initialization failed. Things to check:");
    Serial.println("* is a card is inserted?");
    Serial.println("* Is your wiring correct?");
    Serial.println("* did you change the chipSelect pin to match your shield or module?");
    return;
  } else {
   Serial.println("Wiring is correct and a card is present.");
  }
 
  if (!volume.init(card)) {
    Serial.println("Could not find FAT16/FAT32 partition.\nMake sure you've formatted the card");
    return;
  }

  if (!SD.begin(4)) {
    Serial.println("initialization failed!");
    return;
  }
  Serial.println("initialization done.");
 
  dataFile = SD.open("examlpe.CSV", FILE_WRITE); //if I comment this out then the list files works
  if (dataFile) {
    Serial.print(F("Writing to test.txt..."));
    dataFile.println("NOW this FILE CREATED");
    dataFile.close();
    Serial.println(F("done."));
  }
 
 
 
   Serial.println("Created File: examlpe.CSV");
     
  // re-open the file for reading:
  dataFile = SD.open("examlpe.CSV");
  if (dataFile) {
    Serial.println("examlpe.CSV:");
   
    // read from the file until there's nothing else in it:
    while (dataFile.available()) {
    Serial.write(dataFile.read());
    }
    // close the file:
    dataFile.close();
  } else {
  // if the file didn't open, print an error:
    Serial.println("error opening test.txt");
  }
}


void loop()
{
  Serial.println("\nFiles found on the card (name, date and size in bytes): ");
  root.openRoot(volume);
  // list all files in the card with date and size
  root.ls(LS_R | LS_DATE | LS_SIZE);
}

cheers
182  Using Arduino / Programming Questions / Re: little question, big problem on: November 13, 2012, 12:33:42 am
Post your modify code and to check values use serial port   
183  Using Arduino / Programming Questions / Re: little question, big problem on: November 12, 2012, 11:39:42 pm
Quote
Yes, as you say what i want is blink the led and after that fade it up and down all the time.
But don't worry, with the clue you have given me i want try it and i will tell you if i can get something or if i need your help again, ok?.

Thanks again for your help !!

Above code showing exact output what you need
184  Using Arduino / Storage / ExtendedDatabaseLibrary in conjunction with the standard Arduino SD library on: November 12, 2012, 11:36:51 pm
I want to use this library ExtendedDatabaseLibrary in conjunction with the standard Arduino SD library. I explore function like readblock and writeblock in "SD2CARD.cpp" but still i am confuse how to use them.
I really appreciate your suggestions

The read and write handlers which i want to use for SDcard


Code:
// Uncomment the line appropriate for your platform
#define TABLE_SIZE 512 // Arduino 168 or greater

// The number of demo records that should be created.  This should be less
// than (TABLE_SIZE - sizeof(EDB_Header)) / sizeof(LogEvent).  If it is higher,
// operations will return EDB_OUT_OF_RANGE for all records outside the usable range.
#define RECORDS_TO_CREATE 10

// Arbitrary record definition for this table.  
// This should be modified to reflect your record needs.
struct LogEvent {
  int id;
  int temperature;
}
logEvent;

// The read and write handlers which i want to use for SDcard
void writer(unsigned long address, byte data)
{
  //EEPROM.write(address, data);
}

byte reader(unsigned long address)
{
  //return EEPROM.read(address);
}

// Create an EDB object with the appropriate write and read handlers
EDB db(&writer, &reader);

void setup()
{
  Serial.begin(9600);
  Serial.println("Extended Database Library + Arduino Internal EEPROM Demo");
  Serial.println();

  db.create(0, TABLE_SIZE, sizeof(logEvent));

  Serial.print("Record Count: "); Serial.println(db.count());

  Serial.println("Creating Records...");
  int recno;
  for (recno = 1; recno <= RECORDS_TO_CREATE; recno++)
  {
    logEvent.id = recno;
    logEvent.temperature = recno * 2;
    db.appendRec(EDB_REC logEvent);
  }

  Serial.print("Record Count: "); Serial.println(db.count());
  for (recno = 1; recno < RECORDS_TO_CREATE; recno++)
  {
    db.readRec(recno, EDB_REC logEvent);
    Serial.print("ID: "); Serial.println(logEvent.id);
    Serial.print("Temp: "); Serial.println(logEvent.temperature);  
  }
}

void loop()
{
}
185  Using Arduino / Programming Questions / Re: little question, big problem on: November 12, 2012, 11:27:46 pm
James C4S says
Quote
Hint, I think you a missing a for() loop or do...while() loop around the part of the code where you increment brightness and call analogWrite.

I could be wrong, but I think you're trying to blink the led once and then fade it up.  That's not what your code says right now.


James C4S right
Cybernetician late to answer.
186  Using Arduino / Programming Questions / Re: little question, big problem on: November 12, 2012, 11:22:20 pm
Just add this statement in loop() and there is no big problem smiley-wink
Code:
  digitalWrite(led, HIGH);
  delay(500);
  digitalWrite(led,LOW);
  delay(1000);
 
  //statement you need do and wihle
  do{
  // set the brightness of pin 9:
  analogWrite(led, brightness);   

  // change the brightness for next time through the loop:
  brightness = brightness + fadeAmount;

  // reverse the direction of the fading at the ends of the fade:
  if (brightness == 0 || brightness == 255) {
    fadeAmount = -fadeAmount ;
  }     
  // wait for 30 milliseconds to see the dimming effect   
  delay(30);
  }while(0 !=brightness);//statement you need
}

cheers
 
187  Using Arduino / Programming Questions / ExtendedDatabaseLibrary in conjunction with the standard Arduino SD library on: November 12, 2012, 10:51:29 pm
I want to use this library ExtendedDatabaseLibrary in conjunction with the standard Arduino SD library. I explore function like readblock and writeblock in "SD2CARD.cpp" but still i am confuse how to use them.
I really appreciate your suggestions

The read and write handlers which i want to use for SDcard


Code:
// Uncomment the line appropriate for your platform
#define TABLE_SIZE 512 // Arduino 168 or greater

// The number of demo records that should be created.  This should be less
// than (TABLE_SIZE - sizeof(EDB_Header)) / sizeof(LogEvent).  If it is higher,
// operations will return EDB_OUT_OF_RANGE for all records outside the usable range.
#define RECORDS_TO_CREATE 10

// Arbitrary record definition for this table.  
// This should be modified to reflect your record needs.
struct LogEvent {
  int id;
  int temperature;
}
logEvent;

// The read and write handlers which i want to use for SDcard
void writer(unsigned long address, byte data)
{
  //EEPROM.write(address, data);
}

byte reader(unsigned long address)
{
  //return EEPROM.read(address);
}

// Create an EDB object with the appropriate write and read handlers
EDB db(&writer, &reader);

void setup()
{
  Serial.begin(9600);
  Serial.println("Extended Database Library + Arduino Internal EEPROM Demo");
  Serial.println();

  db.create(0, TABLE_SIZE, sizeof(logEvent));

  Serial.print("Record Count: "); Serial.println(db.count());

  Serial.println("Creating Records...");
  int recno;
  for (recno = 1; recno <= RECORDS_TO_CREATE; recno++)
  {
    logEvent.id = recno;
    logEvent.temperature = recno * 2;
    db.appendRec(EDB_REC logEvent);
  }

  Serial.print("Record Count: "); Serial.println(db.count());
  for (recno = 1; recno < RECORDS_TO_CREATE; recno++)
  {
    db.readRec(recno, EDB_REC logEvent);
    Serial.print("ID: "); Serial.println(logEvent.id);
    Serial.print("Temp: "); Serial.println(logEvent.temperature);  
  }
}

void loop()
{
}
Pages: 1 ... 11 12 [13]