Interfacing of Two Color LED with Arduino

Two Color LED Overview

A two color LED is a special type of LED that can emit two different colors, typically red and green, from a single package. It has two LEDs connected in opposite directions and is commonly used in status indicators and DIY projects.

Working Principle of Two Color LED

The two color LED contains two internal LEDs connected in inverse parallel. Depending on the polarity of the current applied, one of the two LEDs will light up. Reversing the polarity changes the color, making it ideal for visual signals.

Types of Two Color LEDs

Bi-Color LED (Two Pin)

  • Forward bias in one direction lights up the first color (e.g., red).
  • Reverse bias lights up the second color (e.g., green).
  • Alternating current can create a blended color.

Bi-Color LED (Three Pin)

  • Apply HIGH to one pin and LOW to common to light up one color.
  • Apply HIGH to the other pin for the second color.
  • Alternate both pins rapidly to mix colors.

Requirements

1. Arduino Board

2. Two Color LED (2-pin or 3-pin)

3. 220 ohm resistors

4. Jumper wires

Pin Configuration of Two Color LED

2-Pin Bi-Color LED

  • Pin 1: Connect to a digital I/O pin through a resistor.
  • Pin 2: Connect to another digital I/O pin or GND depending on setup.

3-Pin Bi-Color LED

  • Common Pin (Cathode or Anode): Connect to GND or VCC.
  • Pin 1: Connect to digital I/O pin through resistor (Color 1).
  • Pin 2: Connect to another digital I/O pin through resistor (Color 2).

Wiring the Two Color LED to Arduino

To connect a two color LED to Arduino, use appropriate resistors for each leg. For a 2-pin LED, connect both pins to digital I/O pins and toggle polarity through code. For a 3-pin LED, connect the common pin and control the color pins independently from Arduino.

Algorithm

  1. Initialize Components

    • Connect the two color LED to Arduino using resistors.
    • For 3-pin type, wire both color control pins to digital outputs.
  2. Write the Code

    • Set LED pins as OUTPUT in the setup() function.
    • Use digitalWrite() to turn on a specific color.
    • Create a loop to toggle between colors or blink the LED.
  3. Control LED Behavior

    • Use delay() to create blinking effects.
    • Add logic to switch colors based on input or sensor data.
    • Combine both colors for mixed output if supported.
  4. Test the Project

    • Upload the sketch to the Arduino.
    • Observe the LED switching between colors based on the code logic.
1// Two Color LED with Arduino (2-pin version)
2const int ledPin1 = 8;
3const int ledPin2 = 9;
4
5void setup() {
6  pinMode(ledPin1, OUTPUT);
7  pinMode(ledPin2, OUTPUT);
8}
9
10void loop() {
11  // Red ON
12  digitalWrite(ledPin1, HIGH);
13  digitalWrite(ledPin2, LOW);
14  delay(1000);
15
16  // Green ON
17  digitalWrite(ledPin1, LOW);
18  digitalWrite(ledPin2, HIGH);
19  delay(1000);
20
21  // OFF
22  digitalWrite(ledPin1, LOW);
23  digitalWrite(ledPin2, LOW);
24  delay(1000);
25}
26

Applications of Two Color LEDs

  • Status indicators in electronics
  • Battery level indicators
  • User feedback in embedded systems
  • Signal lights in robotics
  • DIY electronics and art projects
  • Multicolor notification systems

Conclusion

Interfacing a two color LED with Arduino is a simple yet effective way to enhance visual feedback in your projects. Whether you're using it for alerts, status indicators, or fun LED patterns, it’s a versatile component to experiment with.