Hello All, I am working on a device which would use a potentiometer to

Hello All,
I am working on a device which would use a potentiometer to change colors on a neopixel ring and then use a pushbutton to record the color value and send via MQTT. The first part is simple enough, but the second part is more complex since it would need to use a predefined color scale. As FastLED simplfies color scales and arrays better than any other library I’ve worked with, I figured this would be the best place to start!
Does anybody have any advice?

I don’t fully understanding your question, can you explain your question a bit more? Where does the predefined color scale come from? What is the predefined color scale you’ll be using?

When you’re dialing in the color with the potentiometer, what about limiting the colors you’re able to dial in to your predefined color scale at that point in the process?

There isnt any requirement for a color scale, I was basically trying to say the same thing as you suggest with limiting the colors. In general, I need something that can drive the neopixels and be easy enough to translate into an MQTT topic structure. Overall, I’m looking to create a hybrid pushbutton/dial which would function as a light switch for a home automation lighting system. The form will be similar to a pushbutton LED globe crossed with a rotary thermostat. As a dial is turned, a neopixel ring will change color depending on the position of the rotary. When the desired color is found, a button will be pressed to send the position of the dial to a home controller via MQTT from where the actual RGB light bulbs will change to the corresponding color. The neopixels therefore function as the interface instead of the actual target device. Does this make sense?

Are all the LEDs the same color? Do you want to control only hue value?

Sheesh MQTT is the new XML :sob:

For my purposes, yes the LEDs should all be the same color to make controlling the home lighting as simple as possible. I may want to set up simple fade animation for a sleep mode of sorts, but nothing that needs to be implemented right away.

@Andrew_Jawitz ​ in that case map the position of your rotary control to hsv you like, display it on local ring, and transmitt that to your controller on click.

Yes thats exactly what I’m trying to do… I was hoping to find out if there was a specific method for mapping HSV values from a rotary encoder used with FastLED. If not then I may as well use the default Adafruit library since the leds will all be changing colors at the same time…

@Andrew_Jawitz ​ I think your mental model maybe over complicated.

There are many ways to set the color of an led using FastLed. If your rotary control increments a variable at every click, its as easy as passing in that value as hue using CHSV.

You can read out the color of any given led too.

Some updates to report… I decided to look for Rotary Encoder instead of a simple trim pot so as to record digital outputs in increments instead of a simple voltage reading that a trim pot would give… I thought all my problems were solved when I discovered this encoder from Sparkfun which combines a pushbutton and an RGB LED into the same control! https://www.sparkfun.com/products/10982 Of course, nothing is ever quite that easy! In this case it seems like all the encoder libraries for arduino are very old and none of them seem to settle on a standard method (e.g some use interrupt pins, others use pullup resistors and others use capacitors to steady the current etc…) It looks like the closest example of a Rotary Encoder controlling an RGB LED was this project http://twichel.com/projects/LarsonScan/codepage.asp which used the same knob as I’m using but to control a full Neopixel strip along with the embedded LED… Basically, I’m thinking of taking a similar approach only instead of using the encoder to drive a Neopixel strip, I would be using it to send out MQTT messages for later interpretation by a home controller.
Once again, I find myself coming back to FastLED… In this case, I’m thinking it would come in handy as it simplifies RGB commands for anything from very simple LEDs to digitally addressable models like the Neopixel. More to the point is the fact that it can also output to MQTT…

@Stuart_Taylor Can you point to any working examples of using a rotary encoder to pass incremental values as HSV? Otherwise, thats like saying “all you have to do is port FastLED to the ESP8266”… The devil is in the details…

Hi @Andrew_Jawitz ​ the rotary encoding part has nothing to do with Fastled.

Do you have that bit of your code working yet?

Can you turn the knob and increment a counter?

Once you have the counting working, post your cide to padtebin, and share the link here, and we can show you how Fastled will make controlling the LEDs easy. it won’t help with MQTT.

MQTT can transport some value for you, a value fastLed can interpret, but you’ll have to provide the glue here.

@Andrew_Jawitz , here’s a wiki page (by @Juergen_Bruegl ) with a couple of rotary encoder examples.