# Analog LED Support

**URL:** <https://wled.discourse.group/t/analog-led-support/55>\
**Category:** Enhancements\
**Created:** [February 5, 2020, 1:01am UTC](https://wled.discourse.group/t/analog-led-support/55 "2020-02-05T01:01:10Z")\
**Posts on this page:** 13\
**Page:** 3

<div class="post-metadata">

**Author:** ![huggy-d1](https://yyz2.discourse-cdn.com/free1/user_avatar/wled.discourse.group/huggy-d1/32/51_2.png) [@huggy-d1](https://wled.discourse.group/u/huggy-d1)\
**Post date:** [May 11, 2020, 5:02pm UTC](https://wled.discourse.group/t/analog-led-support/55/41 "2020-05-11T17:02:06Z")

</div>

> [@tonyno](#):
>
> if ((color == \_analogLastColor) && (b == \_analogLastBri)){}

Does that help it in your current working version?  
Or changing it to this:

```
void WS2812FX::setRgbwPwm(void) {
  uint32_t nowUp = millis(); // Be aware, millis() rolls over every 49 days
  if (nowUp - _analogLastShow < MIN_SHOW_DELAY) return;
  _analogLastShow = nowUp;

  for (uint16_t i = 0 ; i < 4 ; i++) {   
    RgbwColor color = bus->GetPixelColorRgbw(i);
    byte b = getBrightness();
    if !((color == _analogLastColor) && (b == _analogLastBri)) {
      ledcWrite(i*4+0, color.R*b/255); //RPIN
      ledcWrite(i*4+1, color.G*b/255); //GPIN
      ledcWrite(i*4+2, color.B*b/255); //BPIN
      ledcWrite(i*4+3, color.W*b/255); //BPIN
      _analogLastColor = color;
      _analogLastBri = b;
    }
  }

```

---

<div class="post-metadata">

**Author:** ![tonyno](https://yyz2.discourse-cdn.com/free1/user_avatar/wled.discourse.group/tonyno/32/242_2.png) [@tonyno](https://wled.discourse.group/u/tonyno)\
**Post date:** [May 11, 2020, 6:50pm UTC](https://wled.discourse.group/t/analog-led-support/55/42 "2020-05-11T18:50:12Z")

</div>

This did not change either version that I am testing, but…

I just commented-out that IF and all is well!!

---

<div class="post-metadata">

**Author:** ![lard](https://avatars.discourse-cdn.com/v4/letter/l/b5e925/32.png) [@lard](https://wled.discourse.group/u/lard)\
**Post date:** [June 8, 2020, 1:31pm UTC](https://wled.discourse.group/t/analog-led-support/55/43 "2020-06-08T13:31:55Z")

</div>

Hi,

I’m wanting to do some analog RGB LED strips for a long time, but now i came acros WLED. but i have one quick quiestion, is huggy’s code the only thing to change? or is thear more? otherwise is it mabeu possible to sent the full code to me beacust i’m not great at programming.

---

<div class="post-metadata">

**Author:** ![tonyno](https://yyz2.discourse-cdn.com/free1/user_avatar/wled.discourse.group/tonyno/32/242_2.png) [@tonyno](https://wled.discourse.group/u/tonyno)\
**Post date:** [June 28, 2020, 4:00pm UTC](https://wled.discourse.group/t/analog-led-support/55/44 "2020-06-28T16:00:12Z")

</div>

@lard You don’t need that for just one set of outputs. All you need to do is uncomment `#define WLED_USE_ANALOG_LEDS` and the hardware you are using (H801, BWLT11, SHOJO\_PCB, PLJAKOBS\_PCB) in NpbWrapper.h. If you are using the Magic Home LED controller, that is the default.

@Aircoookie has anything changed in 0.10.0 that would make the code above not work?

---

<div class="post-metadata">

**Author:** ![Aircoookie](https://yyz2.discourse-cdn.com/free1/user_avatar/wled.discourse.group/aircoookie/32/2_2.png) [@Aircoookie](https://wled.discourse.group/u/Aircoookie)\
**Post date:** [June 29, 2020, 8:14am UTC](https://wled.discourse.group/t/analog-led-support/55/45 "2020-06-29T08:14:40Z")

</div>

Hi, above code (referring to post #41) should work in 0.10.0.  
However it is not complete as we need something like

```cpp
ledcSetup(0, 5000, 8);
ledcAttachPin(RPIN, 0);

ledcSetup(1, 5000, 8);
ledcAttachPin(GPIN, 1);

```

as initialization for each analog output on ESP32.

---

<div class="post-metadata">

**Author:** ![tonyno](https://yyz2.discourse-cdn.com/free1/user_avatar/wled.discourse.group/tonyno/32/242_2.png) [@tonyno](https://wled.discourse.group/u/tonyno)\
**Post date:** [June 29, 2020, 11:28am UTC](https://wled.discourse.group/t/analog-led-support/55/46 "2020-06-29T11:28:48Z")

</div>

Thanks. How about _where_ it is now? If you recall, Def3nder had moved that code to FX\_fcn.cpp to try to reduce flicker. Would things change if I put it back in NpbWrapper?

---

<div class="post-metadata">

**Author:** ![Aircoookie](https://yyz2.discourse-cdn.com/free1/user_avatar/wled.discourse.group/aircoookie/32/2_2.png) [@Aircoookie](https://wled.discourse.group/u/Aircoookie)\
**Post date:** [June 29, 2020, 4:03pm UTC](https://wled.discourse.group/t/analog-led-support/55/47 "2020-06-29T16:03:09Z")

</div>

No, that wouldn’t really make a difference I believe, you can move it. The `if` statement with the \_analogLastColor shouldn’t be necessary either for ESP32 (or ESP8266 with core 2.7.0+), since the flicker has already been fixed in the PWM drivers!

---

<div class="post-metadata">

**Author:** ![tonyno](https://yyz2.discourse-cdn.com/free1/user_avatar/wled.discourse.group/tonyno/32/242_2.png) [@tonyno](https://wled.discourse.group/u/tonyno)\
**Post date:** [June 29, 2020, 6:16pm UTC](https://wled.discourse.group/t/analog-led-support/55/48 "2020-06-29T18:16:40Z")

</div>

Great, thanks.

---

<div class="post-metadata">

**Author:** ![kester](https://avatars.discourse-cdn.com/v4/letter/k/b38774/32.png) [@kester](https://wled.discourse.group/u/kester)\
**Post date:** [December 8, 2020, 9:54am UTC](https://wled.discourse.group/t/analog-led-support/55/49 "2020-12-08T09:54:02Z")

</div>

I’ve recently started to use WLED, as I had a bunch of LED strips lying around. Most of them are just analog strips though, but that now works as well - great!  
One thing I noticed though, is that the color channel order doesn’t seem to work for these analog led strips. I’ve got some that are RGB, and other that are GRB. Changing the order through the web interface doens’t seem to actually do anything. As a quick test, I recompiled the code manually changing the SetPixelColor function to switch R and B, and that works fine.  
Is it expected at this point that this wouldn’t work? I’ve been looking through the code, but coulnd’t really figure out what would be wrong (haven’t spend too much time though).

---

<div class="post-metadata">

**Author:** ![tonyno](https://yyz2.discourse-cdn.com/free1/user_avatar/wled.discourse.group/tonyno/32/242_2.png) [@tonyno](https://wled.discourse.group/u/tonyno)\
**Post date:** [December 8, 2020, 12:29pm UTC](https://wled.discourse.group/t/analog-led-support/55/50 "2020-12-08T12:29:29Z")

</div>

That color-order setting is for addressable LEDs.

---

<div class="post-metadata">

**Author:** ![kester](https://avatars.discourse-cdn.com/v4/letter/k/b38774/32.png) [@kester](https://wled.discourse.group/u/kester)\
**Post date:** [December 8, 2020, 1:52pm UTC](https://wled.discourse.group/t/analog-led-support/55/51 "2020-12-08T13:52:45Z")

</div>

ok - I’ll see if I can modify this to also be used for the analog leds easily. If so, I’ll post it here, if not, I’ll just keep using my custom builds 🙂

---

<div class="post-metadata">

**Author:** ![newts](https://yyz2.discourse-cdn.com/free1/user_avatar/wled.discourse.group/newts/32/1098_2.png) [@newts](https://wled.discourse.group/u/newts)\
**Post date:** [January 29, 2021, 10:45pm UTC](https://wled.discourse.group/t/analog-led-support/55/52 "2021-01-29T22:45:12Z")

</div>

Where are we on this now? I set the compile flag for analog but don’t see any PWM coming out and don’t see where to assign the pins. Am I missing something? Is it board specific?  
I tried to chase it down and notice the Ledc structures in the .h are not the same as the current Espressif ones that do have a field for the output pin.  
Anyway, trying to use WLED to replace my older purchased LED controller with an analog strip.  
Thanks!

---

<div class="post-metadata">

**Author:** ![tonyno](https://yyz2.discourse-cdn.com/free1/user_avatar/wled.discourse.group/tonyno/32/242_2.png) [@tonyno](https://wled.discourse.group/u/tonyno)\
**Post date:** [January 29, 2021, 11:26pm UTC](https://wled.discourse.group/t/analog-led-support/55/53 "2021-01-29T23:26:32Z")

</div>

Check here…

> **[Aircoookie/WLED](https://github.com/Aircoookie/WLED/wiki/How-To-Compile-Analog-WLED-.bin-File)**
>
> How-To-Compile-Analog-WLED-.bin-File

[Previous page](https://wled.discourse.group/t/analog-led-support/55.md?page=2)
