Hi, recentrly i saw a video about sending multiple variables via Serial to a software on the computer, and here is the code i saw.
void setup() {
Serial.begin(9600);
}
void loop() {
int sensor1 = analogRead(A0);
int sensor2 = analogRead(A2);
int sensor3 = analogRead(A3);
char text[40];
sprintf(text, "%d,%d,%d/n", sensor1, sensor2, sensor3);
Serial.println(text);
delay(100);
}
Basically what i understood is that sprintf() combines variables and text into an char array and it's better to use this function when u have to combine these 2 elements into a string (tell me if it's wrong).
But the point is: when, for example, you make a serial comunication betwen 2 arduinoes, how do you separe the variables contained in the string that you have just received?
Cheers, Luca.
BTW, here is the video that i saw.