- i want to use a txt file store in my sketch folder named "tmp.txt" - i want to include it in my sketch in a array and use it
const int tmp_data [] = { #include "tmp.txt" };
void setup() {
Serial.begin(9600);
while (!Serial); // wait for serial port to connect. Needed for native USB
Serial.print("At place 0: ");
Serial.println (tmp_data [0]);
Serial.print("At place 7: ");
Serial.println (tmp_data [7]);
Serial.print("At place 15: ");
Serial.print (tmp_data [15]);
} // FIN de setup
void loop() {
} //FIN de loop
The "temp.txt" file is like that , when open with "notepad" : 8,6,4,3,9,7,4,2,1,3,5,4,10,546
This is the compilation error : SKETCH\essai_table_txt\essai_table_txt.ino:25:22: fatal error: tmp.txt: No such file or directory
** #include "tmp.txt"**
The "temp.txt" file is realy in the sketch folder !
Whandall:
From the error message I deduct that the compiler would happily include the *.txt,
but the build process did not copy that file to the build location.
Try renaming the file to tmp.h.
YESS its working !!
const int tmp_data [] = {
#include "tmp.h"
};
Whandall:
And, while it seems to work, I would put the #include on a separate line.
How did you write this ?
#include "tmp.h"
const int tmp_data [] = {
???????
};