“SD库”的版本间的差异

来自YFRobotwiki
跳转至: 导航搜索
 
(未显示1个用户的12个中间版本)
第1行: 第1行:
 +
 +
 
{| border="0" cellpadding="10" width="100%"
 
{| border="0" cellpadding="10" width="100%"
 
|-
 
|-
|width="50%" valign="top" align="left"|
+
|width="30%" valign="top" align="left"|
  
The SD library allows for reading from and writing to SD cards, e.g. on the Arduino Ethernet Shield. It is built on sdfatlib by William Greiman. The library supports FAT16 and FAT32 file systems on standard SD cards and SDHC cards. It uses short 8.3 names for files. 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"). As of version 1.0, the library supports opening multiple files.
+
SD 库允许对SD卡(例如在Arduino Ethernet 扩展板)进行读取或写入操作。它是基于William Greiman 的sdfatlib库编写而成。该库文件支持FAT16和FAT32文件系统在标准的SD卡和SDHC卡上。<font color="darkorenge">'''它使用8.3 格式(例如:12345678.txt)的短文件名。'''</font>传递到SD库函数的文件名可以包含被正斜杠“/”分隔的路径,例如:"directory/filename.txt" 。因为工作目录常常就是SD卡的根目录,所以同一个文件的文件名无论是否包含正斜杠都可以(例如:"/file.txt" 相当于"file.txt" )。从1.0 版本开始,该库支持打开多个文件。
The communication between the microcontroller and the SD card uses SPI, which takes place on digital pins 11, 12, and 13 (on most Arduino boards) or 50, 51, and 52 (Arduino Mega). Additionally, another pin must be used to select the SD card. This can be the hardware SS pin - pin 10 (on most Arduino boards) or pin 53 (on the Mega) - or another pin specified in the call to SD.begin(). Note that even if you don't use the hardware SS pin, it must be left as an output or the SD library won't work.
+
  
 +
单片机和SD卡之间使用[[SPI库|SPI]](Serial Peripheral Interface,串行外设接口)实现通信,发生在数字引脚 11、12和13(大多数Arduino电路板上)或者50、51和52(Arduino Mega上)。此外,另外一个引脚必须用来选择SD卡。这可以是硬件SS引脚 - 引脚10(大多数Arduino电路板上)或者引脚53(Arduino Mega上)-或者SD.begin()调用的另一个指定引脚。'''注意 即使你不使用硬件SS引脚,必须将它作为输出引脚保留下来否则SD库不工作'''。
  
<font color="darkcyan" size="+1">'''Examples'''</font><br>
 
  
'''The SD class provides functions for accessing the SD card and manipulating its files and directories.'''
 
  
:-[[ Datalogger]]: Log data from three analog sensors to a SD card using the SD library
+
<font color="orange" size="+2">'''示例'''</font><br>
  
:-[[ 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
+
:-[[ Datalogger]]: 使用SD库将3个模拟传感器数据记录到SD卡中 / Log data from three analog sensors to a SD card using the SD library
  
:-[[ ReadWrite]]: Read and write data to and from a file on a SD card
+
:-[[ DumpFile]]: 使用SD库从SD卡中读取一个文件并串口打印它 / Read a file from a SD card using the SD library and send it over the serial port
  
:-[[ CardInfo]]: Get information about a SD card
+
:-[[ Files]]: 在SD卡上创建和销毁一个文件 / Create and destroy a file on a SD card
  
 +
:-[[ ReadWrite]]: 对在SD卡上的文件进行读取和写入数据操作 / Read and write data to and from a file on a SD card
  
|width="30%" valign="top" align="left"|
+
:-[[ CardInfo]]: 获取SD卡信息 / Get information about a SD card
  
 +
|width="10%" valign="top" align="left"|
 +
<!-- 空白 -->
  
 +
|width="30%" valign="top" align="left"|
 +
<br><br><br>
  
<font color="darkcyan" size="+1">'''SD Class'''</font><br>
+
<font color="orange" size="+2">'''SD '''</font><br>
 
+
'''The SD class provides functions for accessing the SD card and manipulating its files and directories.'''
+
  
:-[[SD:begin()| begin()]]
+
'''SD 类提供了访问SD卡和操作卡中文件和目录的函数。'''
  
:-[[SD:exists()| exists()]]
+
:-[[SD.begin()| begin()]]
  
:-[[SD:mkdir()| mkdir()]]
+
:-[[SD.exists()| exists()]]
  
:-[[SD:open()| open()]]
+
:-[[SD.mkdir()| mkdir()]]
  
:-[[SD:remove()| remove()]]
+
:-[[SD.open()| open()]]
  
:-[[SD:rmdir()| rmdir()]]
+
:-[[SD.remove()| remove()]]
  
 +
:-[[SD.rmdir()| rmdir()]]
  
<font color="darkcyan" size="+1">'''File class'''</font><br>
+
<br><br>
 +
<font color="orange" size="+2">'''File '''</font><br>
  
'''The File class allows for reading from and writing to individual files on the SD card.'''
+
'''File 类允许读取或写入SD卡上单个文件'''
  
:-[[File:available()| available()]]
+
:-[[File.available()| available()]]
  
:-[[File:close()| close()]]
+
:-[[File.close()| close()]]
  
:-[[File:flush()| flush()]]
+
:-[[File.flush()| flush()]]
  
:-[[File:peek()| peek()]]
+
:-[[File.peek()| peek()]]
  
:-[[File:position()| position()]]
+
:-[[File.position()| position()]]
  
:-[[File:print()| print]]
+
:-[[File.print()| print]]
  
:-[[File:println()| println()]]
+
:-[[File.println()| println()]]
  
:-[[File:seek()| seek()]]
+
:-[[File.seek()| seek()]]
  
:-[[File:size()| size()]]
+
:-[[File.size()| size()]]
  
:-[[File:read()| read()]]
+
:-[[File.read()| read()]]
  
:-[[File:write()| write()]]
+
:-[[File.write()| write()]]
  
:-[[File:isDirectory()| isDirectory()]]
+
:-[[File.isDirectory()| isDirectory()]]
  
:-[[File:openNextFile()| openNextFile()]]
+
:-[[File.openNextFile()| openNextFile()]]
  
:-[[File:rewindDirectory()| rewindDirectory()]]
+
:-[[File.rewindDirectory()| rewindDirectory()]]
  
|width="20%" valign="top" align="left"|
+
|width="10%" valign="top" align="left"|
 
<!-- 空白 -->
 
<!-- 空白 -->
 
|}
 
|}

2015年7月23日 (四) 23:06的最后版本


SD库允许对SD卡(例如在Arduino Ethernet 扩展板)进行读取或写入操作。它是基于William Greiman的sdfatlib库编写而成。该库文件支持FAT16和FAT32文件系统在标准的SD卡和SDHC卡上。它使用8.3格式(例如:12345678.txt)的短文件名。传递到SD库函数的文件名可以包含被正斜杠“/”分隔的路径,例如:"directory/filename.txt"。因为工作目录常常就是SD卡的根目录,所以同一个文件的文件名无论是否包含正斜杠都可以(例如:"/file.txt"相当于"file.txt")。从1.0版本开始,该库支持打开多个文件。

单片机和SD卡之间使用SPI(Serial Peripheral Interface,串行外设接口)实现通信,发生在数字引脚 11、12和13(大多数Arduino电路板上)或者50、51和52(Arduino Mega上)。此外,另外一个引脚必须用来选择SD卡。这可以是硬件SS引脚 - 引脚10(大多数Arduino电路板上)或者引脚53(Arduino Mega上)-或者SD.begin()调用的另一个指定引脚。注意 即使你不使用硬件SS引脚,必须将它作为输出引脚保留下来否则SD库不工作


示例


- Datalogger: 使用SD库将3个模拟传感器数据记录到SD卡中 / Log data from three analog sensors to a SD card using the SD library
- DumpFile: 使用SD库从SD卡中读取一个文件并串口打印它 / Read a file from a SD card using the SD library and send it over the serial port
- Files: 在SD卡上创建和销毁一个文件 / Create and destroy a file on a SD card
- ReadWrite: 对在SD卡上的文件进行读取和写入数据操作 / Read and write data to and from a file on a SD card
- CardInfo: 获取SD卡信息 / Get information about a SD card




SD类

SD类提供了访问SD卡和操作卡中文件和目录的函数。

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



File类

File类允许读取或写入SD卡上单个文件

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




返回Arduino库菜单

返回首页

更多建议和问题欢迎反馈至 YFRobot论坛