I have a question about BT communication between Arduino and HC-05 module using Serial comm. I'm trying to control modes of RGB light on my Arduino nano through BT Terminal on my phone (in the future it will be Android APP) but I'm stuck where I need to check if the command sent is a letter or string with color. Below is the example:
I want to use mode where letter T is set up as a command so I have code:
if (Serial.available()) {
mode = Serial.read();
if( mode == 'T') {doSomething(); }
and it's working perfectly fine but now I wanted to send over BT RGB colour like 255,255,255 and then put it in the code
leds[i].r = redInt;
leds[i].g = greenInt;
leds[i].b = blueInt;
I've tried to save it as a string and then if it's not any of the modes, parse it to the int
's ( redInt
, greenInt
, blueInt
) but I don't know how to do it. I tried with parseInt
, but it's saying it won't work with a string. The question is how to save incoming Serial.read()
as a String and after checking if it's not, the command how to parse it to the 3 separate int
's to let me set up the color?