1. We will be in Read Only mode (no new threads, replies, registration) for several hours as we migrate the forums to upgraded software.

Arduino SD card Read

Discussion in 'Embedded Systems and Microcontrollers' started by Dumken, Dec 20, 2016.

  1. Dumken

    Thread Starter Member

    Oct 7, 2014
    31
    0
    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
     
  2. djsfantasi

    AAC Fanatic!

    Apr 11, 2010
    5,464
    2,067
    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.
     
    Robert Murphy likes this.
  3. A Homeschoolers Workbench

    Member

    Jul 26, 2016
    143
    28
    Here is a video that shows how to make a .txt file
    AIDayley
    also the examples in the library's are very useful
     
  4. spinnaker

    AAC Fanatic!

    Oct 29, 2009
    7,815
    3,716

    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.
     
    Dumken likes this.
  5. AlbertHall

    AAC Fanatic!

    Jun 4, 2014
    8,157
    2,023
    Dumken likes this.
  6. spinnaker

    AAC Fanatic!

    Oct 29, 2009
    7,815
    3,716

    What does this do other than just confuse the TS?
     
  7. spinnaker

    AAC Fanatic!

    Oct 29, 2009
    7,815
    3,716

    I have had enough of your nonsense. On my ignore list. Which is extremely rare for me to do around here.
     
    Robert Murphy and djsfantasi like this.
  8. dannyf

    Well-Known Member

    Sep 13, 2015
    2,196
    422
    an easier approach might be to port Windows and Office to the Arduino so you can run excel natively there.
     
    ErnieM and Robert Murphy like this.
  9. A Homeschoolers Workbench

    Member

    Jul 26, 2016
    143
    28
    Does it have to be a exel file? and what things are you searching for? how much experience do you have programing arduino.
    AIDayley
     
  10. spinnaker

    AAC Fanatic!

    Oct 29, 2009
    7,815
    3,716

    If it is so easy, let us see you port Windows over to an 8-bit, 16MHZ CPU with 32kb.
     
  11. A Homeschoolers Workbench

    Member

    Jul 26, 2016
    143
    28
    upload_2016-12-21_7-19-37.png

    You should be able to take bits and pieces from those 6 file plus a little be of searching on the internet for things that are not in there and be able to patch together a sketch that will work.
    Best of luck AIDayley
     
  12. ErnieM

    AAC Fanatic!

    Apr 24, 2011
    7,989
    1,848
    I fear the implied sarcasm went over some heads.

    Creating an excel file to hold some data on a micro is severe overkill. Try some simpler format that works with text files and the task will be solved.
     
  13. A Homeschoolers Workbench

    Member

    Jul 26, 2016
    143
    28
    This example sketch is a great base
    Code (Text):
    1. /*
    2.   SD card read/write
    3.  
    4. This example shows how to read and write data to and from an SD card file
    5. The circuit:
    6. * SD card attached to SPI bus as follows:
    7. ** MOSI - pin 11
    8. ** MISO - pin 12
    9. ** CLK - pin 13
    10. ** CS - pin 4
    11.  
    12. created   Nov 2010
    13. by David A. Mellis
    14. modified 9 Apr 2012
    15. by Tom Igoe
    16.  
    17. This example code is in the public domain.
    18.  
    19. */
    20.  
    21. #include <SPI.h>
    22. #include <SD.h>
    23.  
    24. File myFile;
    25.  
    26. void setup() {
    27.   // Open serial communications and wait for port to open:
    28.   Serial.begin(9600);
    29.   while (!Serial) {
    30.     ; // wait for serial port to connect. Needed for native USB port only
    31.   }
    32.  
    33.  
    34.   Serial.print("Initializing SD card...");
    35.  
    36.   if (!SD.begin(4)) {
    37.     Serial.println("initialization failed!");
    38.     return;
    39.   }
    40.   Serial.println("initialization done.");
    41.  
    42.   // open the file. note that only one file can be open at a time,
    43.   // so you have to close this one before opening another.
    44.   myFile = SD.open("test.txt", FILE_WRITE);
    45.  
    46.   // if the file opened okay, write to it:
    47.   if (myFile) {
    48.     Serial.print("Writing to test.txt...");
    49.     myFile.println("testing 1, 2, 3.");
    50.     // close the file:
    51.     myFile.close();
    52.     Serial.println("done.");
    53.   } else {
    54.     // if the file didn't open, print an error:
    55.     Serial.println("error opening test.txt");
    56.   }
    57.  
    58.   // re-open the file for reading:
    59.   myFile = SD.open("test.txt");
    60.   if (myFile) {
    61.     Serial.println("test.txt:");
    62.  
    63.     // read from the file until there's nothing else in it:
    64.     while (myFile.available()) {
    65.       Serial.write(myFile.read());
    66.     }
    67.     // close the file:
    68.     myFile.close();
    69.   } else {
    70.     // if the file didn't open, print an error:
    71.     Serial.println("error opening test.txt");
    72.   }
    73. }
    74.  
    75. void loop() {
    76.   // nothing happens after setup
    77. }
    78.  
    79.  
     
  14. spinnaker

    AAC Fanatic!

    Oct 29, 2009
    7,815
    3,716
    I would wait till the TS posts back before putting too much time into this. Low thread count means there is at least a chance TS won't be back.
     
Loading...