Home » Arduino and KY-011 Dual Color LED

Arduino and KY-011 Dual Color LED

by arduinoguy71

In this article, we connect an KY-011 Dual Color LED to an Arduino Uno

The KY-011 Dual Color LED module can emit red and green light. You can adjust the intensity of each color using an Arduino PWM pin or simply switch the LED on/off.

Operating Voltage 2.0v ~ 2.5v
Working Current 10mA
Color Red + Green
Beam Angle 150
Wavelength 571nm + 644nm
Luminosity Intensity (MCD) 20-40; 40-80

Depending on the input voltage, series resistors are recommended.

Series resistor (3.3 V) [Red] 120 Ω
Series resistor (3,3 V) [Green] 120 Ω
Series resistor (5 V) [Red] 220 Ω
Series resistor (5 V) [Green] 220 Ω

Parts Required

You can connect to the module using dupont style jumper wire.

This should work with other Arduino board – I have tried an Uno and Mega

Name   Link
Arduino Uno
37 in one sensor kit
Connecting cables

 

Schematic/Connection

ARDUINO SENSOR
Pin 11 LED Red
Pin 10 LED Green
GND GND

Code Example

This example simply switches the red LED on and off then the green LED on and off

int redLED = 11;
int greenLED = 10;
 
void setup ()
{
  // Initialize output pins for the LEDs
  pinMode (redLED, OUTPUT); 
  pinMode (greenLED, OUTPUT); 
}
 
void loop ()
{
  digitalWrite (redLED, HIGH); // LED is switched on
  digitalWrite (greenLED, LOW); // LED is switched off
  delay (2000);
 
  digitalWrite (redLED, LOW); // LED is switched off
  digitalWrite (greenLED, HIGH); // LED is switched on
  delay (2000);
}

Here is a pwm example

int redLED = 11;
int greenLED = 10;
 
int val;
 
void setup () {
  // Initialize output pins for the LEDs
  pinMode (redLED, OUTPUT); 
  pinMode (greenLED, OUTPUT); 
}

void loop () 
{
   for (val = 255; val> 0; val--)
   {
      analogWrite (greenLED, val);
      analogWrite (redLED, 255-val);
      delay (15);
   }

   for (val = 0; val <255; val++)
   {
      analogWrite (greenLED, val);
      analogWrite (redLED, 255-val);
      delay (15);
   }
}

 

Serial Monitor Output

N/A

Links

https://github.com/getelectronics/ArduinoCode/tree/main/37%20Sensor%20Kit/KY-011_2_Color

 

 

You may also like

This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish. Accept Read More

Adblock Detected

Please support us by disabling your AdBlocker extension from your browsers for our website.