KY-029 Dual Color LED Module

View on Amazon
Overview
About KY-029 Dual Color LED Module
The KY-029 Dual Color LED Module features a 3mm LED capable of emitting red and green light. By adjusting the intensity of each color using PWM, you can create various color combinations. The module operates with a common cathode configuration, simplifying control with microcontrollers.
Get Your KY-029
💡 Prices are subject to change. We earn from qualifying purchases as an Amazon Associate.
KY-029 Specifications
Complete technical specification details for KY-029 Dual Color LED Module
📊 Technical Parameters
KY-029 Pinout
The **KY-029** is a 3-pin two-color LED module (red/green, 3mm):
Visual Pinout Diagram

Pin Types
Quick Tips
**Interface**: PWM control for color intensity,🌈 **Colors**: Red, green, and mixed colors via PWM
**Configuration**: Common cathode (middle pin is GND),⚡ **Current**: 20mA typical per LED
**Resistor**: Current-limiting resistor recommended,🎯 **Applications**: Status indicators, visual feedback, dual-state displays
Pin Descriptions
| Pin Name | Type | Description | Notes |
|---|---|---|---|
1 Pin S (Signal) | Communication | LED anode (red or green) | PWM control for color selection |
2 Pin middle (VCC) | Power | Common cathode (ground) | Connect to GND |
3 Pin - (GND) | Power | Not connected | Leave unconnected (NC) |
Wiring KY-029 to ESP32
To interface the **KY-029** with an **ESP32** for two-color LED control:
Visual Wiring Diagram

Connection Status
Protocol
Pin Connections
| KY-029 Pin | Connection | ESP32 Pin | Description |
|---|---|---|---|
1 Pin S (Signal) Required | GPIO16 | LED control (via current-limiting resistor) | |
2 Pin middle (VCC) Required | GND | Common ground | |
3 Pin - (GND) Optional | N/C | Not connected |
**Current-Limiting Resistor**: Use ~220Ω resistor for LED protection
**PWM Control**: Use PWM for color mixing and brightness control
**GPIO Selection**: Use any PWM-capable GPIO, GPIO16 is just an example
**3.3V Logic**: ESP32's 3.3V output sufficient with proper resistor
KY-029 Troubleshooting
Common issues and solutions to help you get your sensor working
Common Issues
Issue: The LED does not emit any light.
Solutions:
- Ensure proper wiring connections between the module and the microcontroller.
- Verify that the microcontroller's GPIO pins are correctly configured as outputs.
- Check if appropriate current-limiting resistors are used to prevent LED damage.
Issue: The LED displays unexpected colors or brightness levels.
Solutions:
- Confirm that the PWM signals are correctly configured for both red and green LEDs.
- Ensure that the common cathode is properly connected to ground.
- Check for any short circuits or loose connections on the module.
Debugging Tips
Use the Serial Monitor to check for error messages and verify the sensor's output. Add debug prints in your code to track the sensor's state.
Use a multimeter to verify voltage levels and check for continuity in your connections. Ensure the power supply is stable and within the sensor's requirements.
Additional Resources
KY-029 Programming Examples
Ready-to-use code examples for different platforms and frameworks
int led_red = 11; // Pin for red
int led_green = 10; // Pin for green
void setup() {
// Initialization of output pins for the LEDs
pinMode(led_red, OUTPUT);
pinMode(led_green, OUTPUT);
}
void loop() {
digitalWrite(led_red, HIGH); // Red LED is switched on
digitalWrite(led_green, LOW); // Green LED is switched off
delay(3000); // Wait for 3 seconds
digitalWrite(led_red, LOW); // Red LED is switched off
digitalWrite(led_green, HIGH); // Green LED is switched on
delay(3000); // Wait for a further 3 seconds in which the LEDs are then switched over
}This Arduino code alternates between turning on the red and green LEDs every 3 seconds. Pins 11 and 10 are configured as outputs for the red and green LEDs, respectively.
#include <stdio.h>
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "driver/ledc.h"
#include "driver/gpio.h"
#define LED_RED_PIN GPIO_NUM_16
#define LED_GREEN_PIN GPIO_NUM_17
#define LEDC_TIMER LEDC_TIMER_0
#define LEDC_MODE LEDC_LOW_SPEED_MODE
#define LEDC_CHANNEL_RED LEDC_CHANNEL_0
#define LEDC_CHANNEL_GREEN LEDC_CHANNEL_1
#define LEDC_DUTY_RES LEDC_TIMER_8_BIT
#define LEDC_FREQUENCY 5000
void app_main(void) {
// Configure timer for LEDC
ledc_timer_config_t ledc_timer = {
.speed_mode = LEDC_MODE,
.duty_resolution = LEDC_DUTY_RES,
.timer_num = LEDC_TIMER,
.freq_hz = LEDC_FREQUENCY,
.clk_cfg = LEDC_AUTO_CLK
};
ledc_timer_config(&ledc_timer);
// Configure LEDC channel for red LED
ledc_channel_config_t ledc_channel_red = {
.speed_mode = LEDC_MODE,
.channel = LEDC_CHANNEL_RED,
.timer_sel = LEDC_TIMER,
.intr_type = LEDC_INTR_DISABLE,
.gpio_num = LED_RED_PIN,
.duty = 0,
.hpoint = 0
};
ledc_channel_config(&ledc_channel_red);
// Configure LEDC channel for green LED
ledc_channel_config_t ledc_channel_green = {
.speed_mode = LEDC_MODE,
.channel = LEDC_CHANNEL_GREEN,
.timer_sel = LEDC_TIMER,
.intr_type = LEDC_INTR_DISABLE,
.gpio_num = LED_GREEN_PIN,
.duty = 0,
.hpoint = 0
};
ledc_channel_config(&ledc_channel_green);
while (1) {
printf("Red LED ON\n");
ledc_set_duty(LEDC_MODE, LEDC_CHANNEL_RED, 255);
ledc_update_duty(LEDC_MODE, LEDC_CHANNEL_RED);
ledc_set_duty(LEDC_MODE, LEDC_CHANNEL_GREEN, 0);
ledc_update_duty(LEDC_MODE, LEDC_CHANNEL_GREEN);
vTaskDelay(pdMS_TO_TICKS(3000));
printf("Green LED ON\n");
ledc_set_duty(LEDC_MODE, LEDC_CHANNEL_RED, 0);
ledc_update_duty(LEDC_MODE, LEDC_CHANNEL_RED);
ledc_set_duty(LEDC_MODE, LEDC_CHANNEL_GREEN, 255);
ledc_update_duty(LEDC_MODE, LEDC_CHANNEL_GREEN);
vTaskDelay(pdMS_TO_TICKS(3000));
}
}This ESP-IDF code configures GPIO16 and GPIO17 as PWM outputs using the LEDC peripheral. It alternates between turning on the red and green LEDs every 3 seconds, simulating a simple traffic light effect.
light:
- platform: monochromatic
name: "KY-029 Red LED"
output: led_red
- platform: monochromatic
name: "KY-029 Green LED"
output: led_green
output:
- platform: gpio
pin: GPIO16
id: led_red
- platform: gpio
pin: GPIO17
id: led_greenThis ESPHome configuration sets up two monochromatic light entities for the red and green LEDs on GPIO16 and GPIO17. They can be controlled separately in Home Assistant to create different lighting effects.
platformio.ini
[env:esp32]
platform = espressif32
board = esp32dev
framework = arduinomain.cpp
#include <Arduino.h>
#define LED_RED_PIN 16
#define LED_GREEN_PIN 17
void setup() {
pinMode(LED_RED_PIN, OUTPUT);
pinMode(LED_GREEN_PIN, OUTPUT);
Serial.begin(115200);
Serial.println("KY-029 Dual Color LED Module Test");
}
void loop() {
digitalWrite(LED_RED_PIN, HIGH);
digitalWrite(LED_GREEN_PIN, LOW);
Serial.println("Red LED ON");
delay(3000);
digitalWrite(LED_RED_PIN, LOW);
digitalWrite(LED_GREEN_PIN, HIGH);
Serial.println("Green LED ON");
delay(3000);
}This PlatformIO code alternates between turning on the red and green LEDs every 3 seconds, with messages printed to the serial monitor.
import machine
import time
LED_RED_PIN = machine.Pin(16, machine.Pin.OUT)
LED_GREEN_PIN = machine.Pin(17, machine.Pin.OUT)
while True:
LED_RED_PIN.on()
LED_GREEN_PIN.off()
print("Red LED ON")
time.sleep(3)
LED_RED_PIN.off()
LED_GREEN_PIN.on()
print("Green LED ON")
time.sleep(3)This MicroPython script toggles the KY-029 red and green LEDs every 3 seconds using GPIO16 and GPIO17.
Wrapping Up KY-029
The ESP32 KY-029 Dual Color LED Module is a powerful KY-0xx module sensor that offers excellent performance and reliability. With support for multiple development platforms including Arduino, ESP-IDF, ESPHome, PlatformIO, and MicroPython, it's a versatile choice for your IoT projects.
Best Practices
For optimal performance, ensure proper wiring and follow the recommended configuration for your chosen development platform.
Safety First
Always verify power supply requirements and pin connections before powering up your project to avoid potential damage.
Ready to Start Building?
Now that you have all the information you need, it's time to integrate the KY-029 into your ESP32 project and bring your ideas to life!
Explore Alternative Sensors
Looking for alternatives to the KY-029? Check out these similar sensors that might fit your project needs.

KY-023 Dual Axis Joystick Module
The KY-023 is a dual-axis joystick module that provides analog outputs for X and Y positions, along with a digital output for a built-in...

KY-015 Temperature and Humidity Sensor Module
The KY-015 is a temperature and humidity sensor module based on the DHT11 sensor. It provides digital output for temperature and humidity...

KY-050 Ultrasonic Distance Sensor Module
The KY-050 is an ultrasonic distance sensor module capable of measuring distances ranging from 2 cm to 300 cm with a resolution of...





