I'm doing a project with Arduino ESP8266-1 and a RGB LED strip. The ESP sends strings to the Arduino via serial with the name of the colors to be set (example: "red", "yellow", "purple") and I need to convert that string into an RGB value (eg. (255, 100, 255)).
How can I do this?
I've tried to create a list of array with values like this:
int red = {255, 0, 0};
and next in the loop:
String com = "red";
if (com == "red") {
colorLed = red;
}
but with more colors, it's not the best way. What would be a better way?
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…