I'm experimenting with IFTTT and the Particle Photon running FastLED.

I’m experimenting with IFTTT and the Particle Photon running FastLED. IFTTT allows me to call a function on the Particle and pass it a string, and I’d like to convert that string to a solid color to display on my LEDs. Any thoughts on the best way to accomplish this?

I’d love to use the standard named web/HTML color codes (HotPink, Orange, etc.) like this:

leds[0] = CRGB::Red;

But I don’t think it’s possible to use these names at run time. Would you recommend I pass a RGB hex code instead and convert the String to the three values as a part of my receiving function?

You could use the names, but it would be a big switch() or if/else(). If you’re subscribing to an event, you could pass whatever you want. The challenge here is you would need to define something like a struct of uint8_t’s as your data element which would be more work than just parsing a string I think. If you’re just calling a function, you’re limited to a string. Converting a string of chars, say “009,055,238” would be pretty trivial though using substring(from, to).toInt().

This has been done about a thousand ways over time, so dig through the archives too. Network control of FastLED is often discussed here.

Thanks @Peter_Buelow . I ended up parsing the string for HEX values and will forego the color names. In case anyone needs it…

int cloudColor(String c)
{
// Get rid of ‘#’ and convert it to integer
int number = 0;
if (c[0] == ‘#’) number = (int) strtol( &c[1], NULL, 16);
else number = (int) strtol( &c[0], NULL, 16);

// Split them up into r, g, b values
int r = number >> 16;
int g = number >> 8 & 0xFF;
int b = number & 0xFF;

for (int i = 0; i < 256; i++)
{
leds[i] = CRGB(r, g, b);
}
FastLED.show();
}