The KY-009 is a compact RGB LED module designed for creating vibrant and customizable lighting effects. It features three LEDs (Red, Green, and Blue) housed in a single package, allowing for the generation of a wide range of colors through Pulse Width Modulation (PWM). This module is ideal for projects requiring colorful lighting, such as decorative displays, status indicators, or interactive designs. Its small size and ease of use make it a popular choice for hobbyists and professionals alike.
Pin Number | Pin Name | Description |
---|---|---|
1 | R | Red LED anode (connect to PWM pin) |
2 | G | Green LED anode (connect to PWM pin) |
3 | B | Blue LED anode (connect to PWM pin) |
4 | GND | Common cathode (connect to ground) |
The following example demonstrates how to control the KY-009 module using an Arduino UNO. It cycles through different colors by adjusting the PWM signals.
// Define the PWM pins connected to the KY-009 module
const int redPin = 9; // Red LED pin
const int greenPin = 10; // Green LED pin
const int bluePin = 11; // Blue LED pin
void setup() {
// Set the RGB pins as output
pinMode(redPin, OUTPUT);
pinMode(greenPin, OUTPUT);
pinMode(bluePin, OUTPUT);
}
void loop() {
// Set the LED to red
analogWrite(redPin, 255); // Full brightness for red
analogWrite(greenPin, 0); // Green off
analogWrite(bluePin, 0); // Blue off
delay(1000); // Wait 1 second
// Set the LED to green
analogWrite(redPin, 0); // Red off
analogWrite(greenPin, 255); // Full brightness for green
analogWrite(bluePin, 0); // Blue off
delay(1000); // Wait 1 second
// Set the LED to blue
analogWrite(redPin, 0); // Red off
analogWrite(greenPin, 0); // Green off
analogWrite(bluePin, 255); // Full brightness for blue
delay(1000); // Wait 1 second
// Set the LED to white (all colors on)
analogWrite(redPin, 255); // Full brightness for red
analogWrite(greenPin, 255); // Full brightness for green
analogWrite(bluePin, 255); // Full brightness for blue
delay(1000); // Wait 1 second
}
LEDs Not Lighting Up:
Incorrect Colors:
Dim or Flickering LEDs:
By following this documentation, you can effectively integrate the KY-009 RGB LED module into your projects and create stunning lighting effects.