The program reads the data you send through the serial port and saves it in "Pregunta", and then reads all the "Titu.txt" files that are in numbered folders (001, 002, 003 ...), inside another a its time called "Manual", when I deactivate the part of reading the files, the part of reading the serial port works perfectly but when activating the other part nothing works:
#include <string.h>
#include <SD.h>
int ID, RAM, RAM2, c1 , c2, c3;
char Respuesta, Pregunta, cP, Directorio;
File Archivo;
void setup(){
SD.begin(9);
Serial.begin(9600);
Serial.println("Listo");
}
void loop(){
if (Serial.available()){
RAM = 0;
RAM2 = 0;
Pregunta = Serial.read();
while(Serial.available()){
Pregunta = Pregunta + Serial.read();
}
Serial.print(Pregunta);
while(1){
RAM++;
c1 = ((RAM - floor(RAM/10)*10) + 48);
c2 = (((RAM - floor(RAM/100)*100)/10) + 48);
c3 = (floor(RAM/100) + 48);
char cP[3] = {c3, c2, c1};
char Directorio[20] = "Manual/";
strcat(Directorio, Directorio);
strcat(Directorio, "/Titu.txt");
Serial.print(Directorio);
if (SD.exists(Directorio)){
Archivo = SD.open(Directorio);
Respuesta = Archivo.read();
while(Archivo.available()){
Respuesta = Respuesta + Archivo.read();
}
Serial.print(Respuesta);
} else {
break;
}
}
}
}
Until
Serial.print (Pregunta);
is the first part and from to is the second