hey guys,
I need to write only two seperate numbers in serial monitor and save them in a vector as element one and two.
I wrote sth but it only takes the first value and it returns zero for second value.
String input;
String input1;
void loop()
{
if(Serial.available()){
input = Serial.readStringUntil('\n');
input1 = Serial.readStringUntil('\n');
SL[0]= input.toFloat();
SL[1]= input1.toFloat();
Serial.print("You typed: " );
Serial.println(SL[0]);
Serial.println(SL[1]);
}
but as I said it only takes the value for input and returns in SL[0] and ignores SL[1].
if you type both values in one line separated by a space then the second one will be ignored
if you type them separately and press enter in between but wait for too long then the second read might fail (as you try to read without knowing if there is something to read)
of course you need to check that the Serial console is actually sending '\n'...