# Neopixel Configuration

**URL:** <https://klipper.discourse.group/t/neopixel-configuration/5928>\
**Category:** General Discussion\
**Created:** [January 14, 2023, 2:54pm UTC](https://klipper.discourse.group/t/neopixel-configuration/5928 "2023-01-14T14:54:39Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![Wes68](https://avatars.discourse-cdn.com/v4/letter/w/fbc32d/32.png) [@Wes68](https://klipper.discourse.group/u/Wes68)\
**Post date:** [January 14, 2023, 2:54pm UTC](https://klipper.discourse.group/t/neopixel-configuration/5928/1 "2023-01-14T14:54:39Z")

</div>

### Basic Information:

Ender5 Plus  
 Octopus v1.1

Can we discuss configuration of the Neopixel in a little depth.  
I have it declared in printer config with the pin # and the count= sections and the initial colors all set to 1. And that works they all light up.  
I have a simple setup with one strip of 30 lights. 10 left 10 right and 10 front of the bed. I would like to be able to index those sets of ten separately. Mainly keep the ten front lights white to light the bed and the left and right sets to show progress or any other effects my mind might dream up. But I haven’t been able to find any in depth info on configuration yet

Any advice would be most appreciated.

---

<div class="post-metadata">

**Author:** ![jjarosz](https://avatars.discourse-cdn.com/v4/letter/j/22d042/32.png) [@jjarosz](https://klipper.discourse.group/u/jjarosz)\
**Post date:** [January 14, 2023, 5:09pm UTC](https://klipper.discourse.group/t/neopixel-configuration/5928/2 "2023-01-14T17:09:19Z")

</div>

Check out this post, sounds like what you want?

[NeoPixel Led as Progress Bar](https://klipper.discourse.group/t/neopixel-led-as-progress-bar/2710)?

I have a neopixel on my SBC and I use it to display temp gradient of the SBC.

---

<div class="post-metadata">

**Author:** ![George](https://yyz2.discourse-cdn.com/free1/user_avatar/klipper.discourse.group/george/32/3585_2.png) [@George](https://klipper.discourse.group/u/George)\
**Post date:** [January 14, 2023, 5:12pm UTC](https://klipper.discourse.group/t/neopixel-configuration/5928/3 "2023-01-14T17:12:49Z")

</div>

@Wes68 You can use [SET\_LED](https://www.klipper3d.org/G-Codes.html#set_led) INDEX parameter.  
@jjarosz Neopixel Led as Progress Bar doesn’t support subsections of the same led.

---

<div class="post-metadata">

**Author:** ![Sineos](https://yyz2.discourse-cdn.com/free1/user_avatar/klipper.discourse.group/sineos/32/18_2.png) [@Sineos](https://klipper.discourse.group/u/Sineos)\
**Post date:** [January 14, 2023, 5:26pm UTC](https://klipper.discourse.group/t/neopixel-configuration/5928/4 "2023-01-14T17:26:37Z")

</div>

I do not use LEDs but AFAIK grouping within one string is not supported.  
There was a PR which seem to have pointed in this direction but it was not accepted:

> <https://github.com/Klipper3d/klipper/pull/5788>
>
> This adds the functionality to create groups of LEDs to either separate a chain …or combine multiple chains to one big LED chain.
> 
> Configuration is like this:
> \`\`\`
> \[led\_group mygroup\]
> leds:
> neopixel:grbw (2-4,6-7,10)
> neopixel:grb
> dotstar:my\_dotstar (32-35)
> \`\`\`
> 
> The indexing is then done in the order of the group definition. 
> The code was partly taken out from the LED effect module, created by Paul McGowan and maintained by me.
> 
> Signed-off-by: Julian Schill \<j.schill@web.de\>

You might be able to work around with a macro, something like

```auto
gcode:
    {% for i in range(10) %}
    SET_LED LED=<config_name> RED=<value> GREEN=<value> BLUE=<value> WHITE=<value> INDEX={i} TRANSMIT=1 SYNC=0
    {% endfor %}

```

Untested but should set the first 10 LEDs. Do the same for 11 to 20 and 21 to 30

---

<div class="post-metadata">

**Author:** ![Sineos](https://yyz2.discourse-cdn.com/free1/user_avatar/klipper.discourse.group/sineos/32/18_2.png) [@Sineos](https://klipper.discourse.group/u/Sineos)\
**Post date:** [January 15, 2023, 12:52pm UTC](https://klipper.discourse.group/t/neopixel-configuration/5928/5 "2023-01-15T12:52:11Z")

</div>

IIRC the LED chip numbering starts with 1, so the range construct would need something like

```auto
# 1 to 10
{% for i in range(1,11) %}
# 11 to 20
{% for i in range(11,21) %}
# 21 to 30
{% for i in range(21,31) %} 

```

---

<div class="post-metadata">

**Author:** ![Wes68](https://avatars.discourse-cdn.com/v4/letter/w/fbc32d/32.png) [@Wes68](https://klipper.discourse.group/u/Wes68)\
**Post date:** [January 22, 2023, 5:57pm UTC](https://klipper.discourse.group/t/neopixel-configuration/5928/6 "2023-01-22T17:57:49Z")

</div>

So I got this little snippet of code to work in separating my led strip into three sections of 10. Now I just need to learn some more jinja2 and start making my individual sections “DO STUFF” for me.

{% for i in range(1,11) %}  
SET\_LED LED=OctoEnder RED=0 GREEN=0 BLUE=1 WHITE=0 INDEX={i} TRANSMIT=1 SYNC=0  
{% endfor %}

```
{% for i in range(11,21) %}
      SET_LED LED=OctoEnder RED=0 GREEN=1 BLUE=0 WHITE=0 INDEX={i} TRANSMIT=1 SYNC=0
{% endfor %}

{% for i in range(21,31) %}
      SET_LED LED=OctoEnder RED=1 GREEN=0 BLUE=0 WHITE=0 INDEX={i} TRANSMIT=1 SYNC=0
{% endfor %}

```

---

<div class="post-metadata">

**Author:** ![Wes68](https://avatars.discourse-cdn.com/v4/letter/w/fbc32d/32.png) [@Wes68](https://klipper.discourse.group/u/Wes68)\
**Post date:** [January 25, 2023, 11:38pm UTC](https://klipper.discourse.group/t/neopixel-configuration/5928/7 "2023-01-25T23:38:53Z")

</div>

[gcode\_macro L150]  
#Description: Macro to control 30 String Neopixels.  
#10 Left, 10 Center, 10 Right of printer bed  
#Keeping center LEDs as white/offwhite bed light  
gcode:  
{% set x = params.LED | default(octoender) %}  
{% set mode = params.MODE %}

SET\_LED\_TEMPLATE LED={led} TEMPLATE={ ‘led\_’ ~ mode }

[display\_template led\_boot]  
text:  
{% for il in range[1,10] %}  
{% for ic in range(11,21) %}  
{% for ir in range(21,31) %}  
SET\_LED LED={x} RED=1 GREEN=0 BLUE=0 INDEX={il+1} TRANSMIT=1 SYNC=0  
SET\_LED LED={x} RED=1 GREEN=0 BLUE=0 INDEX={ic+1} TRANSMIT=1 SYNC=0  
SET\_LED LED={x} RED=1 GREEN=0 BLUE=0 INDEX={ir+1} TRANSMIT=1 SYNC=0  
{% endfor %}  
{% endfor %}  
{% endfor %}  
++++++++++++++++++++  
I cant figure out what I’m doing wrong here. when I run my macro L150 LED=OctoEnder MODE=boot I expect each section of LEDs (Left, Right, and Center) to change from white to red. just as a test.  
It works until I try to incorporate the DISPLAY\_TEMPLATE section and the SET\_LED\_TEMPLATE section. Once I add that I get the following in console:

5:48 PM  
l150 LED=OctoEnder MODE=boot

5:48 PM  
Unknown LED ‘=’

5:48 PM  
Unknown LED ‘=’

HELP please someone who knows this macro stuff…

---

<div class="post-metadata">

**Author:** ![Wes68](https://avatars.discourse-cdn.com/v4/letter/w/fbc32d/32.png) [@Wes68](https://klipper.discourse.group/u/Wes68)\
**Post date:** [January 25, 2023, 11:39pm UTC](https://klipper.discourse.group/t/neopixel-configuration/5928/8 "2023-01-25T23:39:52Z")

</div>

the code was properly indented before I copied and pasted it…

---

<div class="post-metadata">

**Author:** ![EddyMI3D](https://yyz2.discourse-cdn.com/free1/user_avatar/klipper.discourse.group/eddymi3d/32/1981_2.png) [@EddyMI3D](https://klipper.discourse.group/u/EddyMI3D)\
**Post date:** [February 13, 2025, 7:37am UTC](https://klipper.discourse.group/t/neopixel-configuration/5928/9 "2025-02-13T07:37:25Z")

</div>


