Analog button to control brightness?

I see in the documentation for WLED that I can use a potentiometer as an Analog Button to control brightness.

However I can’t find much in the way of examples or documentation on the topic.

Specifically what I’d like to know is how to wire it up and which pin to connect it to.

I’d think I connect the ends of a potentiometer to 3.3v and ground with the center tap going to the analog pin of the esp. However I don’t know what pin number to fill into wled as the analog pin of a D1 mini is ADC0 at A0 but there is also a G0.

All help is appreciated.

Pot ends to 3.3v and ground, center to an analog input.

All pin numbers in the UI are GPIO.

I think I’m having a similar confusion as Fuzzball.

I know how to wire a pot, but I’m not sure how to configure WLED to use the pot for brightness.

I see that in the “LED Preferences” I can set the pin number for the buttons and use the drop-down menu to set it to “Analog”, but what pin number do I set for ADC0 on the ESP8266 (it does not have a GPIO number, it’s just called ADC0)?

Presumably, once that is set, I can use a macro with “250” in the “double” column to set it to control the brightness, according to this wiki page, which seems slightly out of date.

There are usermods available that use external hardware to handle specific tasks. Perhaps there is a usermod that handles your needs perfectly, or close enough, or maybe just needs a little customization to work.

For ESP8266 assign any unused GPIO. The code will still use A0 (or ADC0) on ESP8266.

Thank you! I actually found this out while rummaging in the code after being pointed to usermods by huggy. I had tried configuring it before, but when I applied 3.3V or 0V to the A0 pin, I got the same result (depending on if it was set to analog or analog inverted). But now that I connected an actual potentiometer, it seems to work (although at one extreme the brightness is 0, then it gets brighter as the pot turns, until it reaches the other extreme, where it turns off the LEDs).

To be honest, while I’ve used WLED for a couple years, it’s always done what I’ve needed, so never dug into it and looked at the source code. It is amazing. I thought it would be huge headache to modify and not mess anything up, but it is also very user friendly!

1 Like

Consider me stupid (no really, please do)
What is the setup exactly. For a n00b like I can;t make heads or tails of these replies

  • a potentiometer has 3 pins : which pins do I need to connect?
  • to which GPIO pins do these connectors to be connectod to?
  • what type of potentiometer is recommended, 1k Ohm, 100k Ohm, more or less?
  • how many revolutions from 0 to max Ohm is recommended?
  • what command in a preset is to be set precisely? Or do I just enter “250” in the double button action?

Thank you in advance for your understanding and patience.

Numbering your bullets…

  1. See Analog button to control brightness? - #2 by tonyno
  2. Any of your ESPs analog inputs.
  3. Almost anything. I’d use 10k.
  4. Doesn’t matter.
  5. Correct.
1 Like

Apologies for my late reaction. But thanks for the reply and the info, it is very helpfull

I cannot turn off the strip via console or with api (& T = 2) because the analog button turns on again immediately. in the same way if I use an analog button to control the primary color (value 200) then I will no longer be able to change the color from the computer or app, because the analog button controls the color. Where am I wrong?

Nowhere! The analog pot overrules the app control. By default, the brightness potentiometer will turn the lights off if adjusted to either the minimum or maximum adjustment. You might be able to add in a SPST switch to disconnect the pot from ADC0 to restore app control, but I have not tested such a thing.

In theory, you should be able to control both brightness and pattern by using a rotary encoder and a screen, while still maintaining all features of the UI. I believe there are already usermods created to implement this.

Analog is ABSOLUTE.

1 Like

I think I solved it by removing the resistance that prevented the analog button from turning off at 0v. Now it works fine. the analog value seems to “sleep” until the button is moved

1 Like

That is indeed how I programmed it.
But as soon as analog value changes it wil override whatever else is applied.

1 Like

Perfect job, congratulations.
the added resistance between the potentiometer and GND (as suggested on the wiki) cancels the shutdown also from the pc or second button even if the potentiometer is not touched. In practice, the resistance cancels the “sleep” of the potentiometer

1 Like