I've searched google and can't find any examples of Arduino reading a text file.
is it possible to get arduino to read lines from a text file. The text file only contains 3 lines of strings, and each line is only about 9 characters in length
First you have to send the text file to your Arduino via the serial port.
You know how to do this?
You can send files via "Hyperterminal" or you can write a small application yourself. For example in Borland Delphi.
Then your Arduino has to check the incoming string and take it apart.
But if you write your own application for sending text files, maybe you could better take the file apart in the program running at your computer and send 3 different strings via serial.
In the Arduino you receive them in 3 different variables, and you got what you want!!
Basically my external program will send 3 values, which i can contol the time interval and terminating character. I would like to be able to display these 3 different values on 3 different positions on an LCD screen.
I just don't know how to control the data properly and read it into 3 different variables so that it can then be displayed properly
const int MAX_LEN = 21; // the max digits
char strValue[MAX_LEN + 1]; // add one for the terminating null
int index = 0;
void loop()
{
delay (100);
if( Serial.available())
{
char ch = Serial.read();
if(index < MAX_LEN && ch != 13) // 13 is ascii value of carriage return
{
strValue[index++] = ch; // add the ASCII character to the string;
}
else
{
// here when buffer full or on the first non digit
strValue[index] = 0; // terminate the string with a 0
//char value = atof(strValue); // use atof to convert the string to a float
index = 0; // reset the index for the next string
lcd.setCursor(0,0);
Serial.println(strValue);
lcd.print(strValue);
lcd.setCursor(0,0);
lcd.print(" ");
}
}
dont know if oyu noticed but i had updated the code, after i noticed the type, i was actually uaing character 13 for a carrige return.
The problem i have is how the heck do i read the the second lot of characters being streamed through the serial port into a second variable and then print at a different position on the lcd.