29
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
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]