WLED v0.13.0 button implementation example (+ some issues)

Hi all,

I have searching all over for a simple overview of how to implement a momentary button to cycle through presets and could not find any (may be due to lack of proper “google skillz”) So this is an attempt to list what I did to make it work and also … some issues I noticed of which I hope Aircookie could address them

Disclaimer : I am terrible at coding, even the whole JSON library is abracadabra for me (heck, even CSS is a mystery to me) which is why I used the HTTP API. Anyways, this is what I did:

The goal of the setup was to enable a “real” interface enabling basic functions without the need for software UI or even wifi reception. This is going to be implemented in a lamp for my daughter that will double as a wake up light. She can choose and define the various effects. After that the buttons will be the main interfacing to WLED.
This might also make it possible to (temporarily) disable WIFI on the esp8266 as to improve LAN security.

Hardware setup :

  • esp8266, WEMOS D1 mini clone
  • Button 1 connection : GPIO 0 (pin D3) + GND
  • Button 2 connection : GPIO 1 (pin RX) + GND

Software: WLED v0.13.0 beta 3

Config => LED preferences

  • button 0 pin : 0, pushbutton
  • button 1 pin : 1, pushbutton

Config : Time & macros

  • button 0 short : (preset) 20
  • button 0 long : (preset) 21
  • button 1 short : (preset) 30
  • button 1 long : (preset) 31
  • button 1 double : (preset) 32

Main UI => presets

  • preset 1 to preset 5 have all a certain effect
  • no emtpy presets between 1 and 5
  • preset 6 does not exist, is not used or set
  • preset 7 => API command : &PL=1
  • preset 8-19 do not exist, are not used or set
  • preset 20 => &PL=~ (this is the API command to jump to next preset)
  • preset 21 => &T=2 (API command to turn esp8266 on/off)
  • preset 30 => &A=~5 (increase brightness by steps of 5)
  • preset 31 => &A=2 (reset to very low brightness)
  • preset 32 => &A=125 (jump straight to half of full brightness, since I hardly ever use 100%)

What does this do?
Button 0:

  • When turned off, short pressing the button turns it on and jumps straight to preferred preset (in my case 1)
  • Again short pressing the button makes it jump to the next preset
  • When at preset 5, again short pressing the button makes it jump to preset 1
  • long press will turn the setup off
  • either long or short press will turn it back on again

Button 1

  • short press : increases brightness with small increments
  • long press resets to lowest level
  • double click jumps to 50% brightness

What I do not understand / Issues I have found in my setup

  • I need to leave a preset empty (in the example preset 6) before the &PL=1 command otherwise the last effect preset is skipped entirely before jumping back to the first one.
  • Also, adding new presets after defining the “&PL=1” does not show the new presets, they are simply ignored. Until you re-apply that specific API command (even if you reuse the same preset number)
  • this does not show when simple changing already defined presets
  • you could set the double press to go the previous preset (API would be : &PL=~- ), but this does not seem to work all the time in v0.13.0. I haven’t tried it with v0.12.1

Both these issues do not show when using 0.12.1

  • I do not have skip a preset before using &PL=1
  • New presets or changed presets are not ignored

P.S. I absolutely love the addition of another button in v0.13.0. I really hope this is going to be expanded to more buttons in the future

1 Like


I would recommend that you change preset 20 to PL=~&P1=1&P2=5. This sets the range of the cycle to 1-5. In your case it is not strictly required, since 1-5 is the default, but if you wanted to cycle through more (or less) presets, it would be required.

I’m not sure that I understand the second problem you are experiencing. Do you mean that, if you apply PL=1 once, then change e.g. the effect of preset 1, and then apply PL=1 again, it doesn’t update to the new effect?

Sounds like even more buttons would be of use for your application :slight_smile:
2 is only the default (4 on ESP32), it is possible to raise it up to 10 buttons by custom compiling setting WLED_MAX_BUTTONS in const.h. The only reason 2 is the default is saving memory.


Awesome. I’ll definitely try that.
And about changing the button default, I’ll ask my brother to look at the code. It should be right up his alley

So I tried your suggestion and (of course) it works.
But how does this line work exactly? I can’t figure that one out.
I kinow that when I change the “5” to “8” it continues until preset 8, but what is the logic behind the PL=~&P1=1&P2= …??

P1 is the lower limit and P2 is the upper limit.


It is getting more clear to me. I didn’t get the “first cycle preset” description and that you can add more instructions. Thanks.

However, I am probably asking more of these n00b-like question :slight_smile:

Hello, could you pass me the diagram of how you have the button connected to the wemos d1 mini? I do it according to your descriptions and it doesn’t work for me. Many thanks in advance.