Paul for(int k =0 ; k<15;k++){value[k]=0;} this is to reset all the char in the array so when the next value is read old values doesn't exist. I tried setting the first value of the char array to 0 it didn't work i got the second number continued by the first number.
I was thinking of using strtod() to convert strings to double and then use it.
The code seems to complex to me so I switched to the one I started with i am working on both now.
I have a great improvement on the first one and my novel worked!
String input_line [50];
int input_pos = -1;
int x = 0;
if (Serial.available() >0){
Serial.print("Arduino heard you say: ");
while ((Serial.available () > 0)&& ( x!= 1))
{
char inByte = Serial.read ();
switch (inByte)
{
case '\n': // end of text
x= 1;
// reset buffer for next time
break;
case ',':
input_pos++;
break;
default:
input_line[input_pos] = input_line[input_pos] + inByte;
break;
} // end of switch
}
}
if(x ==1)
{
Serial.println();
Serial.print(input_line[0]);
Serial.println();
Serial.print(input_line[1]);
Serial.println();
Serial.print(input_line[2]);
Serial.println();
though I am getting the last 2 values only the first one is not there here is the output
Arduino heard you say: Arduino heard you say: Arduino heard you say: Arduino heard you say:
60
40.6355
Arduino heard you say:
Moderator edit:
</mark> <mark>[code]</mark> <mark>
</mark> <mark>[/code]</mark> <mark>
tags added.