hi
I used an ethernet shield for read an SDcard, on it I have a file.txt
Card initialization and open file is ok.
but, next I'm in fog for read what it contain.
my .txt file contain int
ex:
1000
2000
3000
4000
one integer (as "long" type) by line.(min 0, max 999940)
the length of the file is more 200000 line.
my way is to read the file, line after line, one line each 10ms, in a loop process.
value, after is convert to control DCmotor, but it's an other step...
if anyone can clear me for how do this !
here the code, where I am...
but the process to how get each line he's not clear for me... it's a part of shadow...
#include <SD.h>
/*
On the Ethernet Shield, CS is pin 4. Note that even if it's not
used as the CS pin, the hardware CS pin (10 on most Arduino boards,
53 on the Mega) must be left as an output or the SD library
*/
const int chipSelect = 4;
void setup()
{
Serial.begin(9600);
Serial.print("Initializing SD card...");
pinMode(53, OUTPUT); // cs pin is an output
// see if card ready----------------------------
if (!SD.begin(chipSelect))
{
Serial.println("Card failed");
return;
}
Serial.println("card Ready");
// Read the file -------------------------------
File logFile = SD.open("testfile.txt");
// if the file is available
if (logFile)
{
Serial.println ("reading file");
while (logFile.available());
}
// if the file not open
else {
Serial.println("error read file");
return;
}
}
void loop()
{
File dataFile = SD.open ("testfile.txt", FILE_READ);
if (dataFile)
{
long dataString = dataFile.read() ;
}
Serial.println(dataString);
}
else
{
Serial.println ("couldn't read file");
}
delay (10);
}