Skip to main content

LED Effects

With its flexibility and relative ease of use, programmable LEDs (Addressable LEDs) are gradually replacing RGB LEDs. Each individual LED element can display the full spectrum of colors at extremely high speeds, making them ideal for creating various lighting effects.

Configuring the strips​

Power off before operation

Before connecting, disconnecting, or replacing LED strips, data cables, or power cables, completely shut down the printer and disconnect the power supply. Do not wire, modify wiring, or touch exposed terminals while the power is on.

In your configuration file, each LED strip or chain connected to an IO pin must have a definition. You need to define the data pin (and clock pin if applicable) for each strip, as well as the number of LEDs in the chain. LED effect instances can use multiple types of strips with different color orders simultaneously, but each strip must first be defined by its type.

[neopixel panel_ring]
pin: <data_pin> # Data pin
chain_count: 16 # Number of LEDs

Configuring the effects​

In a more abstract sense, an effect is the state the LED strip is in. An effect can consist of 1 LED or 100 LEDs. There can be 1 effect layer or 10 effect layers. All of this is arbitrary and scalable. This means the only limit on the number of layers and LEDs that can run simultaneously is the processing power of the host operating system. In initial testing, over 100 LEDs and 12 effect layers were run simultaneously at 24 FPS on a Raspberry Pi 4.

Basic layer definition​

In our example printer, there is a ring of 16 Neopixel LEDs located on the front panel, and a short section of Neopixel LEDs next to the hotend used to illuminate the print.

Additionally, there are 5 Dotstar LEDs beneath the heatbed. Pins in the configuration below use placeholders; replace them according to your motherboard's documentation.

[neopixel panel_ring] # Front panel ring strip
pin: <panel_ring_pin>
chain_count: 16

[neopixel tool_lights] # Tool head lights
pin: <tool_lights_pin>
chain_count: 6

[dotstar bed_lights] # Heatbed lights
data_pin: <dotstar_data_pin> # Dotstar needs a data pin
clock_pin: <dotstar_clock_pin> # Dotstar needs a clock pin
chain_count: 5

We want the ring strip to light up light blue and breathe (gradually brighten and dim) when the printer comes online.

[led_effect panel_idle] # Define effect named panel_idle
autostart: true # Start automatically on boot
frame_rate: 24 # Frame rate (FPS)
leds: # Strips to apply the effect to
neopixel:panel_ring
layers: # Effect layer definitions
breathing 10 1 top (.5,.5,1) # Breathing effect Speed 10 Cutoff 1 Top blend mode Color (0.5,0.5,1) [Light Blue]

This defines an effect named panel_idle.

Controlling the effects​

Effects can be either active or inactive. Inactive effects output no color data, whereas active effects return color data, which are summed additively across each LED they run on.

Activating and deactivating effects​

Our example effect can be activated by running the G-Code command SET_LED_EFFECT EFFECT=panel_idle. To stop all other effects currently running on the LEDs used by the new effect, set the REPLACE parameter to 1: SET_LED_EFFECT EFFECT=panel_idle REPLACE=1 Running the command SET_LED_EFFECT EFFECT=panel_idle STOP=1 will deactivate this specific effect again. To deactivate all effects, we can use the G-Code command STOP_LED_EFFECTS. To deactivate effects only on specific LEDs, we can specify the LEDS parameter: STOP_LED_EFFECTS LEDS="neopixel:panel_ring" You can also specify indices (see below): STOP_LED_EFFECTS LEDS="neopixel:panel_ring (1-7)". Only one LED parameter can be specified at a time. To stop effects on multiple LEDs, we must run the command multiple times.

Fading in and out​

Effects can be faded in and out by specifying the FADETIME parameter: SET_LED_EFFECT EFFECT=panel_idle FADETIME=1.0 Fades the effect in over 1 second. Running SET_LED_EFFECT EFFECT=panel_idle STOP=1 FADETIME=1.0 fades it out over 1 second. We can also fade out all effects by running STOP_LED_EFFECTS FADETIME=1.0. Crossfading between effects can also be achieved by combining the REPLACE parameter with SET_LED_EFFECT (see above): SET_LED_EFFECT EFFECT=panel_idle REPLACE=1 FADETIME=1.0

Additional effect level parameters​

  • autostart: true - Automatically start the effect on boot.
  • frame_rate: - Sets the frame rate (frames per second) of the effect.
  • run_on_error: - (Requires patched MCU firmware. Not currently supported.)
  • heater: - Specifies the heater for a heater effect. Use extruder for the extruder, heater_bed for the heatbed. For temperature fans or sensors, add the type and use quotes. Example: heater: "temperature_fan myfan"
  • analog_pin: - Specifies the pin for effects requiring an analog signal.
  • stepper: - Specifies the axis for a stepper effect. Possible values are: x, y, and z. Example: stepper: x
  • endstops: - Specifies the endstops that trigger the homing effect. Multiple endstops can be specified as a comma-separated list. Possible values are: x, y, z, and probe. Example: endstops: x, y

Defining LEDs​

The leds: section is a list of Neopixel or Dotstar strips that make up this effect. Both types can be used for the same effect. Each strip is defined on its own line under the leds: section and indented.

leds:
neopixel:panel_ring
neopixel:tool_lights
dotstar:bed_lights

Additionally, you can decide to show the effect only on specific LEDs. This is done by providing the LED indices to use after the strip name. Indices can be a list or a range. Ranges can also be reversed to invert the effect direction. If indices are omitted, the entire strip is used.

Likewise, the same strip can be used twice in one effect with different LED specifications if needed.

leds:
neopixel:tool_lights # Use the entire tool_lights strip
neopixel:panel_ring (1-7) # Use LEDs 1 to 7 of the panel_ring strip
neopixel:panel_ring (16-9) # Use LEDs 16 to 9 of the panel_ring strip (reversed)
dotstar:bed_lights (1,3,5) # Use LEDs 1, 3, and 5 of the bed_lights strip

Defining Effect Layers​

Effects are generated frame by frame. Each frame contains a number of pixels equal to the number of LEDs defined for that effect. Therefore, an effect specifying 22 LEDs will have 22 pixels per frame.

Each effect layer is generated as a single frame. Each layer's frame is blended with the next to produce the final effect. Blending is cumulative, and how colors are blended is defined by the blending mode of the top layer. Each effect layer is listed on its own line, and each layer has its own settings.

Most effect layers (such as breathing and gradient) are pre-rendered when Klipper starts to save computational overhead later. Other effects (like Fire and Twinkle) are rendered on demand.

Each layer is defined using the following parameters:

  • Layer name - The type of effect (e.g., static, breathing, fire, etc.)
  • Effect Rate - A numeric parameter controlling the speed, period, or intensity of the effect (meaning varies by effect)
  • Cutoff - Another numeric parameter, typically controlling the length, decay, or threshold of the effect (meaning varies by effect)
  • Blending mode - Defines how this layer blends with the layers below it (e.g., top, add, screen, etc.)
  • Color palette - Defines the colors used by the effect, formatted as (R, G, B) or (R, G, B, W), with values ranging from 0.0 to 1.0

Each layer must be defined on a separate line, and each line must be indented. The length of the palette can be arbitrary but may be compressed based on the frame size or number of LEDs on the strip. Colors are defined as groups of Red, Green, Blue, and (optionally) White. The white channel is only used for RGBW LEDs and is ignored on RGB LEDs. Each color ranges from 0.0 to 1.0 as a decimal. Thus, yellow should use (1.0, 1.0, 0.0). For white, use (1.0, 1.0, 1.0) on RGB LEDs and (0.0, 0.0, 0.0, 1.0) on RGBW LEDs.

Individual colors must be enclosed in parentheses and separated by commas.

Some example palettes:

Rainbow (1.0, 0.0, 0.0),(0.0, 1.0, 0.0),(0.0, 0.0, 1.0) # Red -> Green -> Blue Fire (0.0, 0.0, 0.0),(1.0, 0.0, 0.0),(1.0, 1.0, 0.0),(1.0, 1.0, 1.0) # Black -> Red -> Yellow -> White Blue Comet (0.8, 1.0, 1.0),(0.0, 0.8, 1.0),(0.0, 0.0, 1.0) # Light Cyan -> Cyan Blue -> Deep Blue

layers:
breathing .5 0 screen (0,.1,1), (0,1,.5), (0, 1,1), (0,.1,.5) # Breathing Speed 0.5 Cutoff 0 Screen blend mode 4 shades of blue
static 1 0 bottom (1,.1,0), (1,.1,0), (1,.1,0), (1,1,0) # Static Speed 1 Cutoff 0 Bottom blend mode Orange (repeated 4 times)

Several effects are available.

Static​

Effect Rate: Unused, but must be provided Cutoff: Unused, but must be provided Palette: Colors are blended evenly across the strip Displays a single color without changing. If a palette with multiple colors is provided, the colors are blended evenly across the LEDs based on hue differences.

LinearFade​

Effect Rate: 3 Duration (seconds) for one complete cycle Cutoff: 0 Unused, but must be provided Palette: Colors are cycled sequentially LEDs linearly fade between colors. If a palette with multiple colors is provided, it will cycle through those colors in the order specified in the palette. The Effect Rate parameter controls the time it takes to traverse all the colors.

Breathing​

Effect Rate: 3 Duration (seconds) for one complete breath cycle (bright -> dim -> bright) Cutoff: 0 Unused, but must be provided Palette: Colors are cycled sequentially Colors gradually brighten and then dim (breathe). If a palette with multiple colors is provided, it will cycle through those colors in the order specified. The Effect Rate parameter controls the time it takes for one "breath".

Effect Rate: 1 Duration (seconds) for one complete cycle (on -> off -> on) Cutoff: 0.5 Proportion of time the LED is on (between 0 and 1) Palette: Colors are cycled sequentially LEDs are fully on or fully off according to the effect speed. If a palette with multiple colors is provided, it will cycle through those colors in the specified order.

Strobe​

Effect Rate: 1 Number of strobing flashes per second Cutoff: 1.5 Determines the decay rate. Higher values mean faster decay Palette: Colors are cycled sequentially LEDs flash fully on, then decay and turn off over time. If a palette with multiple colors is provided, it will cycle through those colors in the specified order. The Effect Rate controls how many times the lights flash per second. The Cutoff parameter controls the decay rate. 1.5 is a good decay rate value.

Twinkle​

Effect Rate: 1 Increases the probability of an LED lighting up. Cutoff: .25 Determines the decay rate. Higher values mean faster decay Palette: Color is chosen randomly Random flashes along the strip with decay. If a palette is specified, a color is chosen randomly from it.

Gradient​

Effect Rate: 1 Speed of the gradient cycling, negative values change direction. Cutoff: 1 Number of gradients across the chain (higher value means individual gradients are shorter) Palette: A linear gradient with even spacing. Colors from the palette are mixed into a linear gradient along the length of the strip. The Effect Rate parameter controls the speed of color cycling. Negative values of Effect Rate change the direction of the gradient cycle (right-to-left vs. left-to-right). Cutoff determines the gradient length relative to the chain length. Higher values result in more, shorter gradients across the LEDs (e.g., a value of 2 means 2 gradients across the chain length).

Pattern​

Effect Rate: 1 Time interval (seconds) for the pattern to move Cutoff: 1 Number of LED positions the pattern moves each shift Palette: The pattern to be shifted The palette is applied as a repeating pattern along the chain and shifts along it. The Effect Rate determines the time between shifts (seconds), and the Cutoff determines the number of LED positions the pattern shifts each time.

Comet​

Effect Rate: 1 Speed of the comet's movement, negative values change direction Cutoff: 1 Length of the comet's tail (relative) Palette: Color of the "comet head" and the gradient of the "tail" A point of light moves across the LEDs with a decaying trail. Direction can be controlled by using a negative Effect Rate value. Palette colors determine the color of the comet and its trail. The first color in the palette defines the comet's "head" color, and the remaining colors are blended into the "tail".

Chase​

Effect Rate: 1 Speed of the point movement, negative values change direction Cutoff: 1 Length of the tail (relative) Palette: Color of the "head" and the gradient of the "tail" Setup is identical to Comet, but features multiple points chasing each other.

Heater​

Effect Rate: 1 Minimum temperature (°C) to activate the effect Cutoff: 0 Whether to disable the effect after reaching the target temperature (1=disable, 0=keep static) Palette: Color values blended from cold to hot This effect activates when the specified heater is active or its temperature is above the specified minimum. For example, if the heater is turned on and a target temperature is set, the LEDs will cycle through the gradient colors until the target temperature is reached. Once the target is reached, the last color of the gradient is used, and the effect becomes essentially a static color until the heater state changes. If the Cutoff parameter is provided (set to 1), the effect will be disabled after reaching the target temperature. If the heater is turned off, the colors will follow this pattern in reverse until the temperature falls below the minimum specified in the configuration. LEDs can only serve as a status hint and are not a safe basis for touching the hotend or heatbed; always check the actual temperature before touching, and wait for the hotend and heatbed to cool sufficiently.

Temperature​

Effect Rate: 20 Cold end temperature (°C) Cutoff: 80 Hot end temperature (°C) Palette: Color values blended from cold to hot The temperature of the configured heater determines the color displayed from the gradient palette. When only one color is defined in the palette, the brightness of that color is determined by the temperature.

Fire​

Effect Rate: 45 Probability of a "spark" occurring Cutoff: 40 "Cooling" rate Palette: Color values blended from "cold" to "hot" The Arduino FastLED library includes an example program called Fire2012WithPalette. This effect is a port of that program. It simulates a fire by "igniting" an LED. "Heat" from this LED propagates along the strip and gradually cools. A higher spark rate causes more heat to accumulate at the bottom of the strip, resulting in a more intense fire. Changing the cooling rate makes the overall fire longer or shorter.

HeaterFire​

Effect Rate: 1 Minimum temperature (°C) to activate the effect Cutoff: 0 Whether to disable the effect after reaching the target temperature (1=disable, 0=keep) Palette: Color values blended from "cold" to "hot" A fire effect that responds to the temperature of a specified heater. The fire starts as a small ember and increases in intensity as the heater reaches its target temperature. If the Cutoff parameter is set to 1, the effect will disable once the target temperature is reached; otherwise, it remains active until the heater is turned off.

AnalogPin​

Effect Rate: 10 Multiplier for the input signal Cutoff: 40 Minimum threshold to trigger the effect (raw value or voltage percentage) Palette: Color values for blending This effect uses a value read from an analog pin to determine the color. If multiple colors are specified in the palette, one is selected based on the pin's value. If only one color is specified, the brightness is proportional to the pin's value. This feature is only suitable for connecting finished potentiometer modules compatible with the motherboard's ADC voltage range or supported low-voltage signal modules. Do not connect unknown voltage sources, signals or power outputs exceeding the motherboard's allowable range directly to analog pins, as this may damage the control board.

Stepper​

Effect Rate: 4 Number of tail LEDs (negative value fills all LEDs before the stepper position) Cutoff: 4 Number of head LEDs (negative value fills all LEDs after the stepper position) Palette: Color values for blending The position of the specified stepper motor is represented by the first color in the palette. The remaining colors in the gradient are blended and mirrored on both sides. As the stepper motor position changes relative to the axis length, the light moves up and down the strip. Note that the effect itself updates the stepper motor position every half second (based on reported stepper position, similar to the GET_POSITION gcode command). It is not real-time. A negative Effect Rate will fill the entire strip before the stepper position, and a negative Cutoff will fill the entire strip after the stepper position.

StepperColor​

Effect Rate: 1 Position scaling factor Cutoff: 0 Position offset Palette: Color values for blending The LED color is determined by the position of the stepper motor. The position is mapped to a value between 0 and 100, then multiplied by the Effect Rate and added to the Cutoff as an offset. This result determines the lookup position in the palette, which acts as a gradient of specified color values.

Progress​

Effect Rate: 4 Number of tail LEDs (negative value fills all LEDs before the progress position) Cutoff: 4 Number of head LEDs (negative value fills all LEDs after the progress position) Palette: Color values for blending Configured exactly like the Stepper effect, but this layer reports the print progress instead of the stepper position.

Homing​

Effect Rate: 1 Determines the decay rate. Higher values mean slower decay (fade-out time) Cutoff: 0 Unused, but must be provided Palette: Colors are cycled sequentially During the homing process, when an endstop is triggered, the LEDs light up and fade out again. The Effect Rate determines the time it takes to fade out. If a palette with multiple colors is provided, it will cycle through those colors in the specified order.

Effect Layer Blending​

If you have used image editing software, you may be familiar with color blending between image layers. Several common color blending techniques have been added for blending LED layers. Layers defined in the configuration are ordered from top to bottom (layers lower down in the config file are considered "bottom" layers, layers higher up are "top" layers).

If 3 layers are defined, the bottom layer is blended with the middle layer first. Then the resulting layer is blended with the top layer. Even if a blend mode is specified, the bottom layer is never blended with anything (it acts as the base).

Layer blending is always evaluated from bottom to top.

Since values cannot exceed 100% brightness or fall below 0% darkness, they are clamped within this range as floating-point numbers (0.0 - 1.0).

bottom​

No blending is performed; the color channel values of the bottom layer are used. (b) (Bottom layer color)

top​

No blending is performed; the color channel values of the top layer are used. (t) (Top layer color)

add​

( t + b ) # Top layer color + Bottom layer color

Color channels (Red, Green, Blue) are added to each other. This results in brighter channels.

subtract​

( b - t ) # Bottom layer color - Top layer color

Subtracts the top layer from the bottom layer. This causes similar colors to darken.

subtract_b​

( t - b ) # Top layer color - Bottom layer color

Subtracts the bottom layer from the top layer. This causes similar colors to darken.

difference​

abs( t - b ) # |Top layer color - Bottom layer color|

The brighter of the two channels minus the darker one. ( |t - b| )

average​

( t + b ) / 2 # (Top layer color + Bottom layer color) / 2

Averages the channels.

multiply​

( t * b ) # Top layer color * Bottom layer color

Channels are multiplied, which tends to darken colors.

divide​

( t / b ) # Top layer color / Bottom layer color

Channels are divided, which tends to lighten colors, often resulting in white.

divide_inv​

( b / t ) # Bottom layer color / Top layer color

Similar to divide, but bottom is divided by top.

screen​

1 - ( 1 - t ) * ( 1 - b ) # 1 - (1 - Top layer color) * (1 - Bottom layer color)

Inverts the values, multiplies them, then inverts again. Similar to divide, it produces lighter colors.

lighten​

max( t, b ) # Takes the maximum of t and b for each channel

Uses the lighter of the color channels. ( max(t, b) )

darken​

min( t, b ) # Takes the minimum of t and b for each channel

Opposite of lighten, uses the darker of the color channels. ( min(t, b) )

overlay​

( 2*t*b if t > .5 else 1 - 2*(1-t)*(1-b) ) # Conditional blending

Overlay is a combination of multiply and screen. This has a similar effect of increasing contrast.

Sample Configurations​

das Blinkenlights (Critical Error Warning Lights)​

In the event of a critical error, all LED strips breathe red synchronously to provide a visible indication of an error condition on the printer. This effect is disabled during normal operation and only initiates when the MCU enters a shutdown state (currently not supported).

[led_effect critical_error]
leds:
neopixel:tool_lights
neopixel:bed_lights
layers:
strobe 1 1.5 add (1.0, 1.0, 1.0) # Strobe White
breathing 2 0 difference (0.95, 0.0, 0.0) # Breathing Red (difference blend with below creates pulsing)
static 1 0 top (1.0, 0.0, 0.0) # Static Solid Red (Base)
autostart: false # Do not auto-start
frame_rate: 24 # 24 FPS
run_on_error: true # (Planned feature: run on error)

Bed Idle with Temperature​

[led_effect bed_effects]
leds:
neopixel:bed_lights # Applied to bed strip
autostart: true
frame_rate: 24
heater: heater_bed # Associated bed heater
layers:
heater 50 0 add (1,1,0),(1,0,0) # Heater effect: Activate temp >50°C, Gradient from Yellow (1,1,0) to Red (1,0,0)
static 0 0 top (1,0,0) # Static Red layer (Top, shows solid red when target temp is reached)

Brightness Controlled By Potentiometer​

Power off before operation

Before connecting a potentiometer, fan speed wire, or any analog signal, completely shut down the printer and disconnect the power supply. Only use finished modules or wiring harnesses compatible with the motherboard's ADC voltage range. Do not connect unknown voltage sources, signals, or power outputs exceeding the motherboard's allowable range directly to analog pins.

This is an example of how to use the Analog Pin effect with layer blending to control light brightness. It is recommended to use a finished potentiometer module compatible with the board's interface and connect it to the allowed analog input port according to the motherboard documentation. The Effect Rate and Cutoff values need to be adjusted for the specific potentiometer and circuit board combination.

[led_effect bed_effects]
leds:
neopixel:bed_lights
autostart: true
frame_rate: 24
analog_pin: <analog_input_pin> # Analog input pin
layers:
analogpin 10 0 subtract (1,1,1) # Analog pin effect: Multiplier 10 Threshold 0 Subtract blend mode White (1,1,1) (Higher value -> more white subtracted -> darker)
static 0 0 top (1,1,1) # Static Solid White layer (Base brightness)

Progress Bar​

Using a single LED strip, the print progress is shown as a light blue line on a dark blue background.

[led_effect progress_bar]
leds:
neopixel:progress_lights # Progress bar strip
autostart: true
frame_rate: 24
layers:
progress -1 0 add ( 0, 0, 1),( 0, 0.1, 0.6) # Progress effect: Negative value fills left side, Add blend mode, Gradient from Deep Blue (0,0,1) to Mid Blue (0,0.1,0.6)
static 0 0 top ( 0, 0, 0.1) # Static Dark Blue background layer (Top)

Frequently Asked Questions​

My LEDs flicker randomly​

This is usually due to some kind of signal problem. Most programmable LEDs use a specific communication protocol. It typically involves sending data bits at specific intervals, followed by a reset/latch signal to tell them to illuminate. They will hold the last color they were set to until told to do something else.

In most programmable LED implementations within printer firmware, color data is sent once when a gcode command is executed, and not sent again until another command. They will hold that color as long as the initial signal was received correctly.

In this specific implementation, color data is updated at fixed intervals determined by the effect frame rate. Therefore, 10 frames per second means sending color updates to the LEDs 10 times per second.

The data line is susceptible to electromagnetic interference from other electronics on the printer. When such interference is present, it can cause the data sent to the LEDs to be malformed.

To mitigate this, try insulating the data line or isolating it from other wires. Keep the data line as short as possible. This is especially problematic for 32-bit boards which typically output data signals at 3.3V.

Ringing and reflections on the data line can also degrade signal integrity, especially if the cable to the first LED is quite long. To improve data line reflection, prioritize using finished LED adapter cables with series resistors, signal conditioning modules, or shorter data cables. Modifying wiring yourself is not recommended; if wiring harnesses must be handled, completely power off the printer and disconnect the power supply first.

Another source of flickering is voltage drop. Depending on the set brightness, each programmable LED consumes between 20 and 60mA of power. If they are running on a power supply that cannot provide sufficient power (e.g., the internal regulator of a printer motherboard), this can manifest as flickering or the entire strip being dimmer.

The LEDs at the end of my strip are not as bright as the rest​

This is usually related to the LEDs at the end of the strip not receiving as much power as those at the beginning. The solution is to use finished power injection cables with connectors, an appropriately sized dedicated 5V power supply, or replace the strip with a shorter/lower power one. Modifying VCC and GND wires yourself is not recommended. All LED power wire adjustments must be done with the printer completely powered off and disconnected from the power supply.

My color is incorrect​

Different chip manufacturers and chip types use slightly different color data protocols. Some specify the color order as Red, Green, Blue, while others specify it as Green, Red, Blue. The LED strip configuration has an optional parameter in the 'neopixel' section that can set the color order.

color_order: GRB (for example, if the strip is actually in GRB order but displays green when RGB data is sent)

If you are unsure of the LED color order and want to test it, you can comment out or disable all configured effects and use gcode commands to directly set the strip color.

SET_LED LED=<config_name> RED=1 GREEN=0 BLUE=0 TRANSMIT=1 (for example SET_LED LED=panel_ring RED=1 GREEN=0 BLUE=0 TRANSMIT=1)

This command should turn the entire strip red. If the strip turns green, then it uses GRB color order.

Some LEDs, such as SK6812, also have a white channel. For these LEDs, the color order can be set to: color_order: GRBW

  • Note: Onboard LEDs on FLY mainboards/toolboards generally need to be configured as color_order: GRB (some LED beads with a white channel require color_order: GRBW; please refer to the corresponding product documentation for details)

Loading...