Skip to main content

LED Warning Light Configuration

The LED warning light (three-color signal light) is used to visually display the printer's operating status. This article introduces its wiring method and Klipper configuration.

Voltage Description

LED warning lights come in various input voltage specifications. This article uses the 24V version as an example. Please verify voltage compatibility based on the actual model used.

Wiring Instructions

Cable Color Definition

ColorFunctionWiring Location
GrayCommon positiveConnect to 24V power positive terminal (e.g., 24V fan supply)
RedRed light controlConnect to the mainboard fan control signal pin
GreenGreen light controlConnect to the mainboard fan control signal pin
YellowYellow light controlConnect to the mainboard fan control signal pin

Control Polarity

FLY printer mainboards default to using negative control:

  • The positive terminal (gray wire) of the LED warning light connects to 24V power
  • The control wires (red/green/yellow) of the LED warning light connect to the mainboard GPIO pins
  • When the mainboard outputs a low level, the corresponding color lights up
Loading...

Klipper Configuration

[output_pin led_red]
pin: PD12 # Red light control pin
pwm: False
value: 0 # Default off
shutdown_value: 1 # Automatically turns on the red light when Klipper errors

[output_pin led_green]
pin: PD13 # Green light control pin
pwm: False
value: 0

[output_pin led_yellow]
pin: PD14 # Yellow light control pin
pwm: False
value: 0
Pin Description

The above uses PD12, PD13, and PD14 as example pins. Please modify them according to the available GPIO on your actual mainboard.

Red Light Fail-Safe Mechanism

The red light implements a fail-safe mechanism via shutdown_value: 1:

  • Normal Operation: The red light is controlled by macros and remains off under normal conditions
  • Error/Disconnection: When Klipper enters a Shutdown state, the red light is automatically set to on without any macro intervention.
  • This is a hardware-level safety mechanism. Even if macro logic fails, the red light correctly indicates a fault.

Status Macros

[gcode_macro LED_STATUS]
description: Set LED warning light status
gcode:
{% set STATUS = params.STATUS|default("idle")|lower %}

# First turn off all lights
SET_PIN PIN=led_red VALUE=0
SET_PIN PIN=led_green VALUE=0
SET_PIN PIN=led_yellow VALUE=0

# Set lights according to status (active low: VALUE=1 means pin outputs low level, light on)
{% if STATUS == "printing" %}
SET_PIN PIN=led_green VALUE=1
SET_PIN PIN=led_yellow VALUE=1
{% elif STATUS == "ready" %}
SET_PIN PIN=led_green VALUE=1
{% elif STATUS == "warning" %}
SET_PIN PIN=led_yellow VALUE=1
{% elif STATUS == "error" %}
SET_PIN PIN=led_red VALUE=1
{% endif %}

Status Description

Status ParameterLight EffectUse Case
printingGreen + Yellow onCurrently printing
readyGreen onKlipper connected, printer ready
warningYellow onWarning state (e.g., abnormal temperature but no error)
errorRed onError occurred, requires attention
idleAll offIdle state (default)

Call example: LED_STATUS STATUS=printing

Automatic State Detection (Optional)

To automatically detect Klipper status without modifying print macros, use the following configuration.

# Status variable macro (for recording the last state to avoid flickering from repeated updates)
[gcode_macro _LED_STATE]
variable_last_status: "unknown"
gcode:
# This macro only stores variables, no action needed

# Automatic state detection
[delayed_gcode LED_AUTO_UPDATE]
initial_duration: 1
gcode:
{% set idle = printer.idle_timeout.state|string|upper %}
{% set printing = printer.print_stats.state|string|upper %}
{% set current = "unknown" %}

# Determine current state
{% if printing == "PRINTING" or printing == "PAUSED" %}
{% set current = "printing" %}
{% elif idle == "READY" or idle == "IDLE" %}
{% set current = "ready" %}
{% endif %}

# Only update LED when state changes to avoid flickering
{% set last = printer["gcode_macro _LED_STATE"].last_status %}
{% if current != last %}
SET_GCODE_VARIABLE MACRO=_LED_STATE VARIABLE=last_status VALUE='"{current}"'
LED_STATUS STATUS={current}
{% endif %}

# Continue polling
UPDATE_DELAYED_GCODE ID=LED_AUTO_UPDATE DURATION=1

State Determination Logic

Klipper StateDetection ConditionLED Effect
Printingprint_stats.state = printing/pausedGreen + Yellow on
Connectedidle_timeout.state = ready/idleGreen on
ErrorKlipper enters ShutdownRed on (handled automatically by shutdown_value)
OtherState not detected aboveAll off

How It Works

  1. The _LED_STATE macro stores the last state for comparison
  2. LED_AUTO_UPDATE checks the Klipper state every second
  3. LED_STATUS is called to update the lights only when the state changes, preventing flickering
  4. When Klipper errors and enters Shutdown, shutdown_value automatically takes over the red light
Loading...