How to read multiple values from Serial Port together?

So I am using 7 potentiometers, an MPU-6050 and a pair of (already paired) HC-05 bluetooth modules. I want to take the readings, send it across the HC-05 to another Arduino and use it to control a bunch of (10) servos using the Mega 2560. My question is, how do I tell the Arduino to treat the 10 readings, which are on the same line, as 10 different variables?

Ex: 724, 925, 359, 1023, 169, 824, 235, 80.25, 133.78, 25.89

These could be the readings sent to the second Arduino via HC-05

HELP!!??

Split that string at the delimiters (you have them already: the commas), then convert the parts each into a value.

if(Serial.available() > 0) {
        received = Serial.readStringUntil(',');
    }

I don't favour the readStringUntil() approach because, by reading each part separately, it will take more time to clear the serial input buffer. Also it makes if very difficult to know which item is which.

Have a look at the examples in Serial Input Basics - simple reliable ways to receive data. There is also a parse example to illustrate how to extract numbers from the received text. And the demo uses a comma as the delimiter between data items.

The idea is to read in all the data before trying to parse any of it. Then the serial input buffer is empty and ready for the next message and there is no doubt about the order of the items.

...R

What happens in that statement if no more characters arrive (infinite loop?), or lots of characters but no comma (buffer overflow?).

wvmarle:
What happens in that statement if no more characters arrive (infinite loop?), or lots of characters but no comma (buffer overflow?).

if the delimiter isnt found, for readstringuntil(), you can use Serial.setTimeout(time in ms); to set amount of time it waits for delimiter.

if u dont wanna use readstringuntil(), u can look at joseph's thread for info.