Once again I have the wrong data type. This is an arduino project.
I have a char array. The last 9 characters are rgb, I get them as triplets. So 000255000.
I need to pass those to a function but as integers, like 0, 255, 0. I'm ok if 000 turns into 0, but I need 045 to turn into 45.
I've tried to cast them, like:
blue = (int)message[11];
blue += (int)message[12];
blue += (int)message[13];
That did not work. I could however cast them to strings,which I did, then I tried: Yes, I know this was not a great idea, but it was worth a shot.
char tempBlue[4];
blue.toCharArray(tempGreen, sizeof(tempGreen));
iBlue = atoi(tempGreen);
That also did not work.
I'm lost as to how to do this. I have no idea how ( if you can ) concatenate integers or I would have tried that.
EDIT------
Am I asking the wrong question. Should I be doing this the reverse way around. Concatenate first then to integer? I have them as characters to begin with.