Go Down

Topic: Reading Sensor Log in TXT File (Read 1 time) previous topic - next topic


Hi everyone,

I'm writing a sensor log in a TXT file in a SD card.  So, I write 1, 2, 3 in a TXT File... So far, so good  8)

But, I need to read this log and store into a int... Here is my problem... The value stored is only the last character. If has a 15 stored in file, the int returns 5.

Code: [Select]

int ior() {

int data;
myFile = SD.open("approved.txt");
  if (myFile){
    while (myfile.available()){
        data = myFile.read();
  return (data);

Somebody could help me?

Thanks in advance...


The value stored is only the last character.

No. The value that YOU store is always the last value read. You could do otherwise, using an array.
The art of getting good answers lies in asking good questions.

Go Up

Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

via Egeo 16
Torino, 10131