• Witaj na Forum Arduino Polska! Zapraszamy do rejestracji!
  • Znajdziesz tutaj wiele informacji na temat hardware / software.
Witaj! Logowanie Rejestracja


Ocena wątku:
  • 0 głosów - średnia: 0
  • 1
  • 2
  • 3
  • 4
  • 5
Karta SD problem z odczytem
#1
jak odczytać z karty na przykład do zmiennej tablicowej
Kod:
/*
  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;
char dana;
void setup()
{
  // Open serial communications and wait for port to open:
  Serial.begin(9600);
  while (!Serial) {
    ; // wait for serial port to connect. Needed for Leonardo only
  }


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

  pinMode(10, OUTPUT);
zapis();

}

void loop()
{

     Serial.println(dana);
      odczyt();
}












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

  myFile = SD.open("test.txt", FILE_WRITE);


  if (myFile) {
    Serial.print("Writing to test.txt...");
    myFile.println("elllllllo");

    myFile.close();
    Serial.println("done.");
  } else {
    // if the file didn't open, print an error:
    Serial.println("error opening test.txt");
  }
}
void odczyt(){
  

  // 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:

      dana=myFile.read();
    
    // close the file:
    myFile.close();
  } else {
    // if the file didn't open, print an error:
    Serial.println("error opening test.txt");
  }
}
 
Odpowiedź
  


Wiadomości w tym wątku
Karta SD problem z odczytem - przez adix - 04-10-2015, 23:06
RE: Karta SD problem z odczytem - przez JasQ - 07-10-2015, 09:29
RE: Karta SD problem z odczytem - przez adix - 08-10-2015, 17:34
RE: Karta SD problem z odczytem - przez JasQ - 09-10-2015, 06:45
RE: Karta SD problem z odczytem - przez adix - 10-10-2015, 22:22
RE: Karta SD problem z odczytem - przez JasQ - 11-10-2015, 00:30
RE: Karta SD problem z odczytem - przez adix - 11-10-2015, 18:54

Skocz do:


Przeglądający: 1 gości