KY-009 RGB Full color LED SMD Module arduino example

This is the KY-009 RGB Full color LED SMD Module.

This module has a 5050 surface mount RGB LED that can be used to create virtually any colour by varying the intensity of the 3 colours by using the PWM output. Resistors will be needed to connect to an Arduino.

Voltage :
Red 1.8 to 2.4VDC
Green 2.8 to 3.6VDC
Blue 2.8 to 3.6VDC

Parts List

Name Link
Arduino Uno UNO R3 CH340G/ATmega328P, compatible for Arduino UNO
Sensor kit 37 IN 1 SENSOR KITS FOR ARDUINO HIGH-QUALITY FREE SHIPPING (Works with Official for Arduino Boards)
connecting wire Free shipping Dupont line 120pcs 20cm male to male + male to female and female to female jumper wire
resistor kit 600PCS Component Kit 1% 1/4W Resistor Pack

 

Connection

This is the connections we used for the LED to avoid potential damage

KY-009 module Resistor value Arduino connection
R 180Ω resistor Pin 11
G 110Ω resistor Pin 10
B 110Ω resistor Pin 9
GND

Code

Example 1

[codesyntax lang=”cpp”]

int redpin = 11; 
int bluepin =10;
int greenpin =9;
 
int val;
 
void setup() 
{
  pinMode(redpin, OUTPUT);
  pinMode(bluepin, OUTPUT);
  pinMode(greenpin, OUTPUT);
  Serial.begin(9600);
}
 

void loop() 
{
  for(val=255; val>0; val--)
  {
   analogWrite(redpin, val);
   analogWrite(bluepin, 255-val);
   analogWrite(greenpin, 128-val);
   delay(1); 
  }
 
  for(val=0; val<255; val++)
  {
   analogWrite(redpin, val);
   analogWrite(bluepin, 255-val);
   analogWrite(greenpin, 128-val);
   delay(1); 
  }

}

[/codesyntax]

Example 2

[codesyntax lang=”cpp”]

int redpin = 11; 
int bluepin =10;
int greenpin =9;
  
void setup ()
{
  // Output pin initialization
  pinMode (redpin, OUTPUT); 
  pinMode (greenpin, OUTPUT);
  pinMode (bluepin, OUTPUT); 
}
  
void loop ()
{
  digitalWrite (redpin, HIGH);   // LED will be switched on
  digitalWrite (greenpin, LOW);  // LED will be switched off
  digitalWrite (bluepin, LOW);   // LED will be switched off
  delay (3000); // Wait for 3 seconds
  
  digitalWrite (redpin, LOW);    // LED will be switched off
  digitalWrite (greenpin, HIGH); // LED will be switched on
  digitalWrite (bluepin, LOW);   // LED will be switched off
  delay (3000); // Wait for 3 seconds
   
  digitalWrite (redpin, LOW);    // LED will be switched off 
  digitalWrite (greenpin, LOW);  // LED will be switched off 
  digitalWrite (bluepin, HIGH);  // LED will be switched on 
  delay (3000); // Waitfor 3 seconds
}

[/codesyntax]

 

 

This div height required for enabling the sticky sidebar
Ad Clicks : Ad Views : Ad Clicks : Ad Views : Ad Clicks : Ad Views :