I like to use strtoul for unsigned integer scanning.
char data[] = "200,201,202";
uint8_t rValue, gValue, bValue;
void setup() {
char* behind;
Serial.begin(115200);
Serial.print(F("data to scan \""));
Serial.print(data);
Serial.println(F("\""));
rValue = strtoul(data, &behind, 0); // allows for hex in 0x.. notation
if (behind != nullptr && *behind == ',') {
behind++;
}
gValue = strtoul(behind, &behind, 0);
if (behind != nullptr && *behind == ',') {
behind++;
}
bValue = strtoul(behind, &behind, 0);
Serial.print(F("parsed values are "));
Serial.print(rValue);
Serial.write(',');
Serial.print(gValue);
Serial.write(',');
Serial.println(bValue);
}
void loop() {}
Output:
data to scan "200,201,202"
parsed values are 200,201,202
You could drop the checks
if (behind != nullptr && *behind == ',') {
if you are absolutely sure about the input format.