|
运行示例SD->listfiles 时遇到问题
发表于 2016-11-5 20:24:48
浏览:6124
|
回复:2
打印
只看该作者
[复制链接]
楼主
运行示例SD->listfiles 时遇到问题
#include <SPI.h>
#include "TF.h"
File root;
void setup() {
// Open serial communications and wait for port to open:
Serial.begin(9600);
while (!Serial) {
; // wait for serial port to connect. Needed for native USB port only
}
Serial.print("Initializing SD card...");
if (!SD.begin()) {
Serial.println("initialization failed!");
return;
}
Serial.println("initialization done.");
root = SD.open("/");
printDirectory(root, 0);
Serial.println("done!");
}
void loop() {
// nothing happens after setup finishes.
}
void printDirectory(File dir, int numTabs) {
while (true) {
File entry = dir.openNextFile();
if (! entry) {
// no more files
break;
}
for (uint8_t i = 0; i < numTabs; i++) {
Serial.print('\t');
}
Serial.print(entry.name());
if (entry.isDirectory()) {
Serial.println("/");
printDirectory(entry, numTabs + 1);
} else {
// files have sizes, directories do not
Serial.print("\t\t");
Serial.println(entry.size(), DEC);
}
entry.close();
}
}
提示如下错误:
C:\Users\钂插叕鑻盶AppData\Local\Temp\arduino_modified_sketch_157250\listfiles.ino: In function 'void printDirectory(LFile, int)':
listfiles:59: error: 'class LFile' has no member named 'openNextFile'
listfiles:67: error: 'class LFile' has no member named 'name'
listfiles:68: error: 'class LFile' has no member named 'isDirectory'
exit status 1
'class LFile' has no member named 'openNextFile'
我是小白,不知如何解决,希望好心人能帮帮忙,在此谢过。
|
|