I'm trying to read a string like this one:
2;12;42;43;34
over a serial connection and split this string afterwards by a ";". So the output would be this array:
(2,12,42,34)
All the stuff runs on an arduino uno. So I made some code:
String read_input;
char read_input_char[20];
char *read_values;
void setup() {
Serial.begin(9600);
Serial.setTimeout(10);
}
void loop() {
if(Serial.available()){
read_input = Serial.readString();
read_input.toCharArray(read_input_char, 20);
read_values = strtok(read_input_char, ";");
Serial.println(read_values[2]);
}
}
However now instead of outputting the 3rd array element it outputs only an '1'. What's wrong?