Hi friends,
i am sending 12,34,56 from Serial Monitor but i just can take 34,56 as first and second variables. How can i get the first part?
void setup(){
Serial.begin(38400);
}
void loop(){
while(Serial.findUntil(",", "\n\r")){
int first = Serial.parseInt();
int second = Serial.parseInt();
int third = Serial.parseInt();
Serial.println(first);
Serial.println(second);
Serial.println(third);
}}
Thank you
Well, that code reads up to a comma first, then reads in three numbers, then reads up to the next comma after the ones it passed while reading the three numbers. If it finds another comma (not counting the ones it passed trying to read three numbers) then it reads in three more numbers.
Since the first comma is after the 12, then the 12 gets passed over in that first search for a ','. At that point there are only 2 numbers left and it tries to read three. So the third one gets nothing.
So using that code, if you want to capture the 12 then you would have to send a ',' in front of it.
You are right, i don't think there is another way to take the first part.
Thank you Delta_G 