Hi,
I'm trying to write code that:
1: Finds the size of a file in bytes
2. Divides the size of the file by 100 bytes (this is needed for a loop)
3. Open the file
4. Select the first 100 bytes
5. Do something with those bytes
6. Select the next 100 bytes and do something and then loop until the end of the file
I can get the file size, open the file and selected the first 100 bytes but how can I make it loop and get the next 100 bytes until the end of the file?
uint8_t myBytes[100];
#include <SD.h>;
File myFile;
int loop_number;
void setup()
{
int sizefile = myFile.size();
loop_number = sizefile / 100;
myFile = SD.open("test.txt");
if (myFile)
{
//read the first 100 bytes
for (int aByte = 0; aByte < 100; aByte++)
{
myBytes[aByte] = myFile.read(); //put the byte read from the file into the array
}
//do something with the 100 bytes
//myFile.close();
}
}