Hi guys thanks for your help.
Right now i made a smaller program just to learn how to use SD properly. I have a txt file in the Sd (user.txt) with 4 users codes. For now i im trying to save it like: user[1]=67202....user[4]61014 but ir doesn't work. The serial shows user[1]=59, user[2]=59, user[3]=59,user[4]=59. Here is my code.
67202
62601
60920
61014
#include <String.h>
#include <SD.h>
int CS=53;
String dataString;
File dataFile;
int i=1;
unsigned long dato;
unsigned long user[100];
void setup(){
Serial.begin(115200);
Serial.println("Initiating SD");
pinMode(CS, OUTPUT);
if(!SD.begin(CS)){
Serial.println("SD failed");
return;
}
Serial.println("SD OK");
leerSD();
}
void leerSD(){
Serial.println("Reading SD...");
dato=0;
dataFile=SD.open("user.txt",FILE_READ);
// read from the file until there's nothing else in it:
while (dataFile.available()&& dataFile.peek() != '\n'){
Serial.write(dataFile.read());
delay(50);
}
asignauser();
}
void asignauser(){
if(i<=4){
user[i]=dataFile.read();
Serial.print("The user");
Serial.print(i);
Serial.print("is:");
Serial.println(user[i]);
i++;
leerSD();
}
loop();
}
void loop(){
}
Many thanks!!