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 forwarding 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 directories.

File class

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

範例

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() 以及 fread(), to access files in the SD card with a correct DOS path of the C: drive, e.g., “C:/datalog.txt“.


函式庫參考主頁面

86Duino 參考的文本是根據 Creative Commons Attribution-ShareAlike 3.0 License,部分文本是從 the Arduino reference 修改的。 參考中的代碼示例已發佈到公共領域。

發表評論

上部へスクロール