Converting from String to Char Array

Hi all!

I would like to convert this string that I will send over from Processing to Arduino "0xB20000 0x000DFF"

How do I convert it to Char Array so I can use it for instance like

Colour[0] in Arduino which will give me "0xB20000"
Colour[1] in Arduino which will give me "0x000DFF"

I have got Serial running already

String str;
str = Serial.readString();

Thanks alot in advance!

Get rid of String (capital S) and use one of the approaches in serial input basics - updated to directly get data into a character array.

You could, of course, work with char arrays in your program to avoid the need to convert from String to string

sterretje:
Get rid of String (capital S) and use one of the approaches in serial input basics - updated to directly get data into a character array.

Does this still work if I'm using Processing to extract data from a JSON file?

UKHeliBob:
toCharArray() - Arduino Reference
You could, of course, work with char arrays in your program to avoid the need to convert from String to string

I'm not sure how to use that...

What am I doing wrong here?

char inChar;
char inData;
String str;

str = Serial.readString();
int str_len = str.length() + 1;
char char_array[str_len];

char_array[0] should give me 0xB20000
char_array[1] should give me 0x000DFF
right?

char char_array[str_len];Declare an array of chars but don't initialise it.

char_array[0] should give me 0xB20000
char_array[1] should give me 0x000DFF

Why would it ?

char_array[0] is the first element of char_array
char_array[1] is the second element of char_array

The first element is '0', the second element is 'x'.

Serial communication has no idea about how the data is created (String, binary stuff, character array). So yes, the Serial Input Basics - updated thread will work; even contains an example how to parse (split) the data.

sterretje:
char_array[0] is the first element of char_array
char_array[1] is the second element of char_array

Serial communication has no idea about how the data is created (String, binary stuff, character array). So yes, the Serial Input Basics - updated thread will work; even contains an example how to parse (split) the data.

I looked at the thread and have no idea how to even start...

I'm very new to Arduino..

Is there no easier way?

Processing sends data over Serial "0xB20000 0x45cfc9 0x95b8e3"
Arduino strings them into str and then does more to process them in such a way that

Colour[1] = 0xB20000
Colour[2] = 0x45cfc9
Colour[3] = 0x95b8e3

?

Or even with what I have now

I tried using char_array[0, 7], still does not give me 0xB20000