- Jun 6, 2020
- 11,559
- 4,422
The rSD library allows reading and writing to SD cards. The Ethernet shield as well as other shields include a SD slot.
The steps required to work with files:
1. Initialize a SD object. You need to pass the CS pin used. See this link for more information:
2. Open a file with a call to SD.OpenRead or SD.OpenReadWrite.
3. Read or write to the file stream with SD.Stream property.
4. Close the file with SD.
Note that opening a different file will close the previous one.
There is a bug in Arduino tool chain that can lead to this error message during compilation:
GetFileAttributesEx E:\arduino\libraries\SD\src\File.cpp E:\arduino\libraries\SD\src/SD.h: The filename, directory name, or volume label syntax is incorrect.
The workaround for this error is to press on Ctrl + P (clean project) before compilation.
Listing files
This is done with a For Each loop and a call to ListFiles:
B4X:
The steps required to work with files:
1. Initialize a SD object. You need to pass the CS pin used. See this link for more information:
برای دیدن لینک ها باید ثبت نام کنید
2. Open a file with a call to SD.OpenRead or SD.OpenReadWrite.
3. Read or write to the file stream with SD.Stream property.
4. Close the file with SD.
Note that opening a different file will close the previous one.
There is a bug in Arduino tool chain that can lead to this error message during compilation:
GetFileAttributesEx E:\arduino\libraries\SD\src\File.cpp E:\arduino\libraries\SD\src/SD.h: The filename, directory name, or volume label syntax is incorrect.
The workaround for this error is to press on Ctrl + P (clean project) before compilation.
Listing files
This is done with a For Each loop and a call to ListFiles:
B4X:
For Each f As File In sd.ListFiles("/")...
برای دیدن لینک ها باید ثبت نام کنید
برای دیدن لینک ها باید ثبت نام کنید