Interfacing the KY-011 2-Color LED Module with evive

Description
Learn how to use the KY-011 2-color LED module with evive. We used two different ‘for’ loops and the PWM pins of the evive board to control the brightness of the LEDs.

Introduction

The KY-011  2-color led is a handy little component that allows two colors ( Red and Green) in a single LED while only having 3 pins

  • Common cathode pin
  • Anode for green led
  • Anode for  red  led

The KY-011 2-color led  emits red and green colors but by applying different voltages on anodes of led we can produce different colors, we will use the PWM pins of our evive board to generate different voltages, click here for more information on PWM

Circuit Diagram

  • Connect common cathode pin of the KY-011 module to the ‘GND’  pin of evive
  • Connect the anode of the green LED to pin number 10 of evive
  • Connect the anode of the red LED to pin number 11 of evive

Arduino Code

We have used two different ‘for’ loops in this code, the first for loop will increase the intensity of the “Red” LED, and the second ‘for’ loop will increase the intensity of the “Green” LED.

/*
 * evive
 * 
 * this code demonstrate Interfacing of KY-011 2-color led module with evive
 * 
 * Created by Punit chotaliya
 * On 19 may, 2018
 * 
*/

  const int redpin = 10;  // redpin of the two color module is connected to pin number 11
  const int greenpin = 8; // greenpin of the two color module is connected to pin number 10
  int  temp;         //temporary variable
  
  void setup() 
  {
  // put your setup code here, to run once:
  
  pinMode(redpin,OUTPUT);       // declaring both red and green pin 
  pinMode(greenpin,OUTPUT);     // as a output pin
 
  }

void loop() 
   {
    // put your main code here, to run repeatedly:
    
    for( temp = 0; temp<255 ;temp+=2)
    {
    
         analogWrite(redpin,temp);       //  increasing the brightness of red led 
         delay(25);
     }
     digitalWrite(redpin,LOW);
     delay(1000);
  

    for( temp = 0; temp<255 ;temp+=2)
    {
    
          analogWrite(greenpin,temp);        //  increasing the brightness of green led
   
         delay(25);
    }
    digitalWrite(greenpin,LOW);
    delay(1000);
   }

Expected Result

Conclusion

In this lesson, we learned how to use the KY-011 2-color LED module with evive. We used two different ‘for’ loops to control the brightness of the Red and Green LEDs. We also used the PWM pins of the evive board to generate different voltages to control the brightness of the LEDs. We hope that this lesson has given you the knowledge to create your own projects using the KY-011 2-color LED module.

Table of Contents