Arduino SD card Read

Thread Starter

Dumken

Joined Oct 7, 2014
31
Good day guys. I want to create a an excel file on my SD card. Then I want to search for some things I'll saved inside the excel file in my SD card and display on LCD. Please how do I do that? Thanks
 

djsfantasi

Joined Apr 11, 2010
9,163
First, you learn how to program an Arduino.

Then you research and choose a shield that can take an SD card.

Next, you experiment with the sample programs that come with the shield's library

Then, you realize how much easier it is to save your file in CSV format with Excel.

If you get this far, let us know.
 

spinnaker

Joined Oct 29, 2009
7,830
Good day guys. I want to create a an excel file on my SD card. Then I want to search for some things I'll saved inside the excel file in my SD card and display on LCD. Please how do I do that? Thanks

You should first start with reading a simple text file. That is going to be complicated enough.

You will find libraries for reading files from an SD card here using a micro-controller.
 
This example sketch is a great base
Code:
/*
  SD card read/write

This example shows how to read and write data to and from an SD card file
The circuit:
* SD card attached to SPI bus as follows:
** MOSI - pin 11
** MISO - pin 12
** CLK - pin 13
** CS - pin 4

created   Nov 2010
by David A. Mellis
modified 9 Apr 2012
by Tom Igoe

This example code is in the public domain.

*/

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

File myFile;

void setup() {
  // Open serial communications and wait for port to open:
  Serial.begin(9600);
  while (!Serial) {
    ; // wait for serial port to connect. Needed for native USB port only
  }


  Serial.print("Initializing SD card...");

  if (!SD.begin(4)) {
    Serial.println("initialization failed!");
    return;
  }
  Serial.println("initialization done.");

  // open the file. note that only one file can be open at a time,
  // so you have to close this one before opening another.
  myFile = SD.open("test.txt", FILE_WRITE);

  // if the file opened okay, write to it:
  if (myFile) {
    Serial.print("Writing to test.txt...");
    myFile.println("testing 1, 2, 3.");
    // close the file:
    myFile.close();
    Serial.println("done.");
  } else {
    // if the file didn't open, print an error:
    Serial.println("error opening test.txt");
  }

  // re-open the file for reading:
  myFile = SD.open("test.txt");
  if (myFile) {
    Serial.println("test.txt:");

    // read from the file until there's nothing else in it:
    while (myFile.available()) {
      Serial.write(myFile.read());
    }
    // close the file:
    myFile.close();
  } else {
    // if the file didn't open, print an error:
    Serial.println("error opening test.txt");
  }
}

void loop() {
  // nothing happens after setup
}
 
Top