What is the best method to read an integer directly from a file (which ever file type is best)

I have some values, between 0 and 255, stored on an sd (can be in any format), which correspond to rgbw color values. There are too many numbers for the on board arduino memory.

What is the go-to method to extract these numbers into integers?

Thank you

Hi,
Google;

arduino sd card tutorial

It will show you some tutorials that may help.

Thanks.. Tom.... :grinning: :+1: :coffee: :australia:

byte RGBW[4];

  for (int i=0; i<4; i++)
   RGBW[i] = file.read();

Would that not read just 4 bytes? I guess the OP is asking how to read all numbers unless I have misunderstood something...

Your question is a bit vague. Are you concerned about changing bytes into integers? If so all you have to do is assign the byte to the integer like this:

byte RedByte = something read from memory
int RedInt = RedByte

Yes. It would read one RGBW value. Repeat for each set of values.

Thank you, do you know how to convert numbers in a text file (like 255) into single bytes (11111111)?

Ok thank you, this helps a lot

255 (decimal notation) and 11111111 (binary notation) and FF (hexadecimal notation) are all the same number. You can represent the same number in different forms, but the value is the same.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.