Quantcast
Channel: Intel Communities: Message List
Viewing all articles
Browse latest Browse all 20046

Re: how to read data from a txt file from sd

$
0
0

Hi luismaya,

 

What message are you getting in the serial monitor? Are you successfully reading from file? You can also use C to code on Galileo using a sketch via the Arduino IDE. It is a lot easier to read and write to a file instead of using the SD.h library. Here is a sample code to include in your sketch.

 

datafile= fopen( "/tmp/datafile" , "r");  if (datafile) {     while (fgets(output, 100, datafile) != NULL)         ;  fclose(datafile);  }  data= atoi(output);

 

Also, don't forget to declare your variable at the beginning of the sketch. since you are using integers, this code should get you started.

char output[100];
FILE * datafile;
int data;

 

If you are more comfortable using the SD library I can also help you with that, i just need to know what messages you are getting in the Serial Monitor.

 

Regards,

Intel_Jesus


Viewing all articles
Browse latest Browse all 20046

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>