787
The KY-011 Two color LED module consists of a common cathode 3mm red/green LED. You can adjust the amount of each color using PWM, so we will use 2 PWM pins on our Arduino later on to demonstrate this
Connection
Its best to use a couple of current limiting resistors since the module does not have any on board
KY-011 | Resistor | Arduino |
G | 330Ω resistor | Pin 10 |
R | 330Ω resistor | Pin 11 |
Y | GND |
Code
[codesyntax lang=”cpp”]
// Arduino test code for KY011 int redpin = 11; // select the pin for the red LED int greenpin = 10; // select the pin for the green LED int val; void setup () { pinMode (redpin, OUTPUT); pinMode (greenpin, OUTPUT); } void loop () { for (val = 255; val> 0; val--) { analogWrite (greenpin, val); analogWrite (redpin, 255-val); delay (15); } for (val = 0; val <255; val++) { analogWrite (greenpin, val); analogWrite (redpin, 255-val); delay (15); } }
[/codesyntax]
Links
37 in 1 box Sensor Kit For Arduino Starters brand in stock