SD Library

The SD library allows for reading from and writing to SD cards in the MicroSD/SD slot of 86Duino. The library supports FAT16 and FAT32 file systems on standard SD cards and SDHC cards. The file names passed to the SD library functions can include paths separated by forward-slashes, /, e.g. “directory/filename.txt“. Because the working directory is always the root of the SD card, a name refers to the same file whether or not it includes a leading slash (e.g. “/file.txt” is equivalent to “file.txt“). The library supports opening multiple files.

Before using the SD card, you should format it to FAT16 or FAT32 file systems. See also the page for some notes on the usage of SD cards.

SD class

The SD class provides functions for accessing the SD card and manipulating its files and directorie.

begin()
exists()
mkdir()
open()
remove()
rmdir()

File class

The File class allows for reading from and writing to individual files on the SD card.

available()
close()
flush()
peek()
position()
print()
println()
seek()
size()
read()
write()
isDirectory()
openNextFile()
rewindDirectory()

Examples

The following are examples of the SD library from the Arduino Tutorial that can work on the 86Duino boards (note that on 86Duino, you don’t need Arduino’s Ethernet and SD card shields shown in these examples):

Datalogger: Log data from three analog sensors to a SD card using the SD library.
DumpFile: Read a file from a SD card using the SD library and send it over the serial port.
Files: Create and destroy a file on a SD card.
ReadWrite: Read and write data to and from a file on a SD card.

Hack

The SD card is treated as a standard hard disk drive by 86Duino’s BIOS, and especially corresponds to the C: drive. So instead of the SD library, you can always employ the file input/output functions of the C programming language, such as fopen() and fread(), to access files in the SD card with a correct DOS path of the C: drive, e.g., “C:/datalog.txt“.


Libraries Reference Home

The text of the 86Duino reference is a modification of the Arduino reference, and is licensed under a Creative Commons Attribution-ShareAlike 3.0 License. Code samples in the reference are released into the public domain.