小编Mar*_*min的帖子

From .txt file in sd card to string variable in Arduino

I'm trying to read a text file in an Arduino SD card reader and copy its text into a string variable, but the function .read always returns -1. How can I solve this problem?

Here's the code:

#include <SPI.h>
#include <SD.h>

File mappa;
String text;

void setup() {
Serial.begin(9600);
while (!Serial) {
  ;
}
Serial.print("Initializing SD card...");
if (!SD.begin(4)) {
  Serial.println("initialization failed!");
  return;
}
Serial.println("initialization done.");

// open the file. note that only one file can be open at a …
Run Code Online (Sandbox Code Playgroud)

string arduino sd-card

2
推荐指数
1
解决办法
5686
查看次数

标签 统计

arduino ×1

sd-card ×1

string ×1