Pages: [1]   Go Down
Author Topic: Reading Sensor Log in TXT File  (Read 1000 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 1
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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  smiley-cool

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:
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...
Logged

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 637
Posts: 50299
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
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.
Logged

Pages: [1]   Go Up
Jump to: