Ah you are right. But in the initial sketch i did have it but no luck. That sketch is here:
#include <LiquidCrystal.h>
#include <string.h>
char inData[80];
char flightdata[80];
byte index = 0;
LiquidCrystal lcd(12, 11, 2, 3, 4, 5);
void setup()
{
Serial.begin(115200);
lcd.begin(20, 4);
}
void loop()
{
while(Serial.available() > 0)
{
char aChar = Serial.read();
if(aChar == '\n')
{
char *p = inData; //point to *p to the string in inData
char *str; //declaring *str
int counter = 0; //initialise the counter
while (str = strtok_r(p, ",", &p)) // delimiter is the comma
{
flightdata[counter] = *str; //use the counter as an index to add each value to the array
counter++; //increment the counter
p = NULL;
}
lcd.setCursor(0, 0);
lcd.print("Speed: "); lcd.print(flightdata[0]); //print out the data stored in the value storage array index '0'
//set cursor to next line using appropiate commands again
lcd.setCursor(0, 1);
lcd.print("Altitude: "); lcd.print(flightdata[1]); //ditto
index = 0;
inData[index] = NULL;
}
else
{
inData[index] = aChar;
index++;
inData[index] = '\0'; // Keep the string NULL terminated
}
}
}