Arduino KY-016 3-color LED module
From
3 color - full color LED module
Contents
Overview
RGB LED module consists of a plug-in full color LED made by R, G, B three pin PWM voltage input can be adjusted Section three primary colors (red / blue / green) strength in order to achieve full color mixing effect. Control of the module with the Arduino can be achieved Cool lighting effects.
Specifications
- the use of plug-in full-color LED
- RGB trichromatic limiting resistor to prevent burnout
- through the PWM adjusting three primary colors can be mixed to obtain different colors
- with a variety of single-chip interface
- the working voltage: 5V
- LED drive mode: common cathode driver
Schematic
- Arduino pin 11 --> Pin R module
- Arduino pin 10 --> Pin G module
- Arduino pin 9 --> Pin B module
- Arduino pin GND --> Pin - module
You don't need any resistors, these are already included on the module.
Example code
//KY016 3-color LED module int redpin = 11; // select the pin for the red LED int bluepin = 10; // select the pin for the blue LED int greenpin = 9 ;// select the pin for the green LED 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 (11, val); analogWrite (10, 255-val); analogWrite (9, 128-val); delay (10); Serial.println (val, DEC); } for (val = 0; val <255; val ++) { analogWrite (11, val); analogWrite (10, 255-val); analogWrite (9, 128-val); delay (10); Serial.println (val, DEC); } }
Simple demo without cables
Example code random
/* Demo for KY-009 and KY-016. Plug the board directly in your Arduino board without using cables. If you turn the board 180° you should use pin 12 as ground and swap the green and blue pin. The demo will over time cycle through all the 16777216 different colors which can be made with 3x8bit. */ int groundpin = 8; // write 0 to get ground int greenpin = 9; // select the pin for the green LED int redpin = 10; // select the pin for the red LED int bluepin = 11; // select the pin for the blue LED void setup () { pinMode (redpin, OUTPUT); pinMode (greenpin, OUTPUT); pinMode (bluepin, OUTPUT); pinMode (groundpin, OUTPUT); digitalWrite (groundpin, LOW); } void loop () { analogWrite (redpin, random(255)); analogWrite (greenpin, random(255)); analogWrite (bluepin, random(255)); delay (300); }