我想从文本文件中读取数据,并希望在Arduino串行监视器上显示它。以下是我从
中提取的代码#include<SD.h>
File myfile;
void setup(){
Serial.begin(9600);
Serial.print("Initializing card...");
// declare default CS pin as OUTPUT
pinMode(53, OUTPUT);
if (!SD.begin(4)) {
Serial.println("initialization of the SD card failed!");
return;
}
Serial.println("initialization of the SDcard is done.");
// open the text file for reading:
myfile = SD.open("help2.txt");
if (myfile){
Serial.println("help2.txt:");
// read all the text written on the file
while (myfile.available()){
Serial.println(myfile.read());
}
// close the file:
myfile.close();
}
else {
// if the file didn't open, report an error:
Serial.println("error opening the text file!");
}
}
void loop(){
}
但是当代码在Arduino上编译和上传时,只有“正在初始化卡...”正在串行监视器上打印。我想获得串行监视器上文本文件中的完整数据。