KY-034 Automatic Flashing Color LED Module

The KY-034 is an automatic flashing color LED module that emits a sequence of seven colors when powered. It's suitable for decorative and visual display applications, providing dynamic lighting effects without the need for external control.

KY-034 Automatic Flashing Color LED Module image
KY-034 · Digital
Digital
Interface
3pins
Connections
3.3-5V
Supply
$1
Typical price
On this page

KY-034 pinout

3 pins · Digital

The KY-034 is a 3-pin automatic color-cycling LED module:

View:
KY-034 Automatic Flashing Color LED Module pinout
PinTypeDescriptionNotes
-PowerGround connection
middlePowerNot connectedLeave unconnected
SCommunicationPower/control inputConnect to HIGH or GPIO pin
  • Interface: Simple power control (no PWM/protocol needed)

  • LED: 5mm automatic color-cycling LED (7 colors)

  • Colors: Red → Green → Blue → Yellow → Cyan → Magenta → White (cycles automatically)

  • Power: 3.3V to 5V operation (via S pin)

  • Automatic: Self-cycling - no external control required

  • Control: Drive S pin HIGH to power LED, LOW to turn off

  • Applications: Decorative lighting, visual indicators, party effects, mood lighting

Wiring the KY-034 to ESP32

3 connections · 1 optional

To interface the KY-034 with an ESP32 for automatic color-cycling LED:

KY-034 Automatic Flashing Color LED Module wiring with ESP32
KY-034 pinESP32 pinPurpose
-GNDGround
middleNCNot connected · optional
SGPIO13 or 3.3VPower control (any GPIO or direct power)
  • Simple Control: Drive S pin HIGH to enable LED, LOW to disable

  • Direct Power: Can connect S directly to 3.3V for always-on operation

  • Auto-Cycling: LED cycles through 7 colors automatically (no code needed)

  • No PWM: This is NOT an RGB LED - colors change automatically via built-in IC

  • Low Current: ~20mA max - safe to drive directly from GPIO

  • No Configuration: Just power on and enjoy the color show

  • Middle Pin: Leave middle pin unconnected (NC)

KY-034 code examples

5 platforms
Platform:

KY-034 Arduino example

Copy
int led = 13; // Declaration of the LED input pin

void setup() {
    pinMode(led, OUTPUT); // Initialization output pin for the LED
}

void loop() {
    digitalWrite(led, HIGH); // LED is switched on
    delay(4000); // Wait for 4 seconds
    digitalWrite(led, LOW); // LED is switched off
    delay(2000); // Wait for another two seconds
}

This Arduino code initializes pin 13 as an output to control the KY-034 module. In the loop, it turns the LED on for 4 seconds and off for 2 seconds repeatedly, allowing the LED to cycle through its automatic color sequence during the on periods.

KY-034 ESP-IDF example

Copy
#include <stdio.h>
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "driver/gpio.h"

#define LED_PIN GPIO_NUM_13

void app_main(void) {
    gpio_config_t io_conf = {
        .intr_type = GPIO_INTR_DISABLE,
        .mode = GPIO_MODE_OUTPUT,
        .pin_bit_mask = (1ULL << LED_PIN),
        .pull_down_en = GPIO_PULLDOWN_DISABLE,
        .pull_up_en = GPIO_PULLUP_DISABLE
    };
    gpio_config(&io_conf);

    printf("KY-034 Automatic Flashing Color LED Test\n");
    while (1) {
        gpio_set_level(LED_PIN, 1); // LED on
        vTaskDelay(pdMS_TO_TICKS(4000));
        gpio_set_level(LED_PIN, 0); // LED off
        vTaskDelay(pdMS_TO_TICKS(2000));
    }
}

This ESP-IDF code configures GPIO13 as an output for the KY-034 module. It turns the LED on for 4 seconds and off for 2 seconds in a loop, allowing the LED to display its automatic color-changing sequence during the on periods.

KY-034 ESPHome example

Copy
light:
  - platform: binary
    name: "KY-034 Flashing Color LED"
    output: ky034_output

output:
  - platform: gpio
    id: ky034_output
    pin: GPIO13

This ESPHome configuration sets up the KY-034 module as a binary light component on GPIO13. The light can be controlled via Home Assistant or other ESPHome-compatible interfaces, turning the LED on to display its automatic color sequence and off as desired.

KY-034 PlatformIO example

Copy
[env:esp32]
platform = espressif32
board = esp32dev
framework = arduino
src/main.cppCopy
#include <Arduino.h>

#define LED_PIN 13

void setup() {
    pinMode(LED_PIN, OUTPUT);
    Serial.begin(115200);
    Serial.println("KY-034 Automatic Flashing Color LED Test");
}

void loop() {
    digitalWrite(LED_PIN, HIGH);
    Serial.println("LED ON");
    delay(4000);
    digitalWrite(LED_PIN, LOW);
    Serial.println("LED OFF");
    delay(2000);
}

This PlatformIO code initializes GPIO13 as an output for the KY-034 module. It turns the LED on for 4 seconds and off for 2 seconds in a loop while printing status messages to the serial monitor.

KY-034 MicroPython example

Copy
import machine
import time

LED_PIN = machine.Pin(13, machine.Pin.OUT)

while True:
    LED_PIN.on()
    print("LED ON")
    time.sleep(4)
    LED_PIN.off()
    print("LED OFF")
    time.sleep(2)

This MicroPython script configures GPIO13 as an output for the KY-034 module. It continuously cycles the LED on for 4 seconds and off for 2 seconds, printing status messages to the console.

KY-034 specifications

From the datasheet
Operating Voltage
3.3V to 5V
LED Type
5mm round head
Color Cycle
Automatic sequence of 7 colors
Dimensions
16.5mm x 18.5mm

About the KY-034

The KY-034 is not an RGB LED, and there’s no way to make it behave like one. The color-changing part happens entirely inside the 5mm LED package itself, which has a tiny driver IC built in that free-runs through a fixed sequence - commonly described as red, green, blue, yellow, purple, cyan and white - the moment power is applied. The “module” around it is just a current-limiting resistor and a 3-pin header; there’s no PWM input, no data line, and no way to pick a color, hold on one, or change the sequence’s timing from the ESP32 side.

That makes the wiring and code about as simple as it gets: drive the signal pin HIGH to power the LED and let it cycle, or LOW to turn it off, and that’s the entire interface. It’s a fine, cheap way to add an eye-catching color-cycling indicator to a project, but anyone who actually needs specific colors on demand - a status LED that turns red for an error and green for OK, for instance - needs an addressable RGB LED like a WS2812B instead, not this module.

KY-034 troubleshooting

2 common issues

LED Not Lighting Up

›

Issue: The LED does not turn on when powered.

Solutions:

  • Verify that the module is connected to the correct voltage (3.3V to 5V).
  • Ensure proper wiring connections between the module and the microcontroller.
  • Check for any damage to the LED or module components.

LED Not Changing Colors

›

Issue: The LED remains a single color and does not cycle through colors.

Solutions:

  • Confirm that the module is receiving continuous power without interruptions.
  • Ensure that the signal pin is set to HIGH to allow the LED to operate.
  • Check for any firmware or code that might be interfering with the LED's operation.

Where to buy the KY-034

KY-034 Automatic Flashing Color LED Module
KY-034 Automatic Flashing Color LED Module
$1per unit, typical
Amazon and AliExpress links are affiliate links - buying through them supports the site at no extra cost to you.

Resources