I have a problem working with strings, cause I lost that C language lecture, so I don't know how to split and string and put the values inside a integer variables.
I've got a string comming from my serial like this: 51,20,11
And I would like to have in the end: A = 51
B = 20
C = 11
where A,B,C are integers.
void loop() {
while (Serial.avaiable()>0) {
data = Serial.read();
char *p = data;
char *str;
while ((str[i] = strtok_r(p, ",", &p)) != NULL){ // delimiter is the semicolon
Serial.println(str);
}
}
}
The serial output give me:
50
22
11
With this I split my string but I don't know how to save the data to an array and then convert it to an integer.