• Arduino
  • Raspberry Pi
  • Raspberry Pi Pico
  • Micro:Bit

This LED module contains two LEDs in the colors red and green, which are connected to each other via a common cathode. This means that both LEDs share the same negative connection, which simplifies the circuit. By controlling the individual LEDs, you can generate different color signals to indicate operating states or warnings, for example. The compact design and easy integration make this module ideal for a variety of applications where colour visualization is required, such as in control systems, displays or decorative projects.

Technical data
Forward voltage 2.0 - 2.5 V
Forward current 20 mA

Series resistors:

Depending on the input voltage, series resistors are required.

Input voltage Series resistor
3.3 V 120 Ω
5 V 220 Ω

Pin assignment


Arduino Sensor
Pin 11 LED Red
Pin 10 LED Green
GND GND

1. Code example: ON/OFF

This code example shows how the integrated LEDs can be changed alternately, every 3 seconds, by means of a definable output pin.

To load the following code example onto your Arduino, we recommend using the Arduino IDE. In the IDE, you can select the appropriate port and board for your device.

Copy the code below into your IDE. To upload the code to your Arduino, simply click on the upload button.

int led_red = 11; // Pin for red
int led_green = 10; // Pin for green
 
void setup() {
  // Initialization of output pins for the LEDs
  pinMode(led_red, OUTPUT); 
  pinMode(led_green, OUTPUT); 
}
// Main program loop
void loop() {
  digitalWrite(led_red, HIGH); // Red LED is switched on
  digitalWrite(led_green, LOW); // green LED is switched off
  delay(3000); // Wait for 3 seconds
 
  digitalWrite(led_red, LOW); // Red LED is switched off
  digitalWrite(led_green, HIGH); // green LED is switched on
  delay(3000); // Wait for a further 3 seconds in which the LEDs are then switched over
}

2. Code example: PWM

Pulse width modulation [PWM] can be used to regulate the brightness of an LED - in this process, the LED is switched on and off at specific time intervals, with the ratio of the switch-on and switch-off times corresponding to a relative brightness. Due to the inertia of human vision, human eyes interpret such on/off behavior as a change in brightness. More information on this topic can be found in this article by Analog IC Tips.

Several LEDs are integrated in this module - by superimposing different brightness levels, different colors can thus be created. This is shown in the following code example.

To load the following code example onto your Arduino, we recommend using the Arduino IDE. In the IDE, you can select the appropriate port and board for your device.

Copy the code below into your IDE. To upload the code to your Arduino, simply click on the upload button.

int led_red = 11; // Pin for red
int led_green = 10; // Pin for green
 
void setup() {
  // Initialization of output pins for the LEDs
  pinMode(led_red, OUTPUT); 
  pinMode(led_green, OUTPUT); 
}
void loop() {
   // Within a For loop, the two LEDs are given different PWM values
   // This creates a color gradient in which different colors are created by mixing different 
   // brightness levels of the two integrated LEDs, different colors are created
   for(int i = 255; i > 0; i--) {
      analogWrite(led_green, i);
      analogWrite(led_red, 255 - i);
      delay(15);
   }
   // In the second For loop, the color gradient is run backwards
   for(int i = 0; i <255; i++) {
      analogWrite(led_green, i);
      analogWrite(led_red, 255 - i);
      delay(15);
   }
}

This LED module contains two LEDs in the colors red and green, which are connected to each other via a common cathode. This means that both LEDs share the same negative connection, which simplifies the circuit. By controlling the individual LEDs, you can generate different color signals to indicate operating states or warnings, for example. The compact design and easy integration make this module ideal for a variety of applications where colour visualization is required, such as in control systems, displays or decorative projects.

Technical data
Forward voltage 2.0 - 2.5 V
Forward current 20 mA

Series resistors:

Depending on the input voltage, series resistors are required.

Input voltage Series resistor
3.3 V [Red] 120 Ω
3,3 V [Green] 120 Ω
5 V [Red] 220 Ω
5 V [Green] 220 Ω

Pin assignment


Raspberry Pi Sensor
GPIO 23 [Pin 16] LED Green
GPIO 24 [Pin 18] LED Red
GND [Pin 6] GND

Code example (ON/OFF)

This code example shows how the integrated LEDs can be changed alternately, every 3 seconds, by means of a definable output pin.

# Required modules are imported and set up
from gpiozero import LED
import time

# Initialization of the LEDs
led_red = LED(24)
led_green = LED(23)

print("LED test [press CTRL+C to end the test]")

# Main program loop
try:
    while True:
        print("LED RED on for 3 seconds")
        led_red.on()  # Red LED is switched on
        led_green.off()  # Green LED is switched off
        time.sleep(3)  # Wait mode for 3 seconds

        print("LED GREEN on for 3 seconds")
        led_red.off()  # Red LED is switched off
        led_green.on()  # Green LED is switched on
        time.sleep(3)  # Wait mode for 3 seconds

# Clean-up work after the program has been completed
except KeyboardInterrupt:
    print("Program was interrupted by user")
    led_red.close()  # Release resources for red LED
    led_green.close()  # Release resources for green LED

}

Code example (PWM)

Pulse width modulation [PWM] can be used to regulate the brightness of an LED - in this process, the LED is switched on and off at specific time intervals, with the ratio of the switch-on and switch-off times corresponding to a relative brightness. Due to the inertia of human vision, human eyes interpret such on/off behavior as a change in brightness. More information on this topic can be found in this article by Analog IC Tips.

Several LEDs are integrated in this module - by superimposing different brightness levels, different colors can thus be created. This is shown in the following code example.

# Required modules are imported and set up
import random, time
from gpiozero import PWMLED

# Initialization of the LEDs
led_red = PWMLED(24)
led_green = PWMLED(23)

# This function generates the actual color
# The color intensity can be changed using the respective color variable
# After the color has been set, the time is defined using "time.sleep",
# how long the color in question should be displayed
def led_color(red, green, pause):
    led_red.value = red / 100  # Value range from 0 to 1
    led_green.value = green / 100
    time.sleep(pause)
    
    led_red.value = 0
    led_green.value = 0

print("LED test [press CTRL+C to end the test]")

# Main program loop:
# This has the task of creating a separate variable for each individual color
# and to run through the color intensity of each individual color from 0-100% using a For loop
# By mixing the different brightness levels of the respective colors
# thus creating a color gradient
try:
    while True:
        for x in range(0, 2):
            for y in range(0, 2):
                print(x, y)
                for i in range(0, 101):
                    led_color(x * i, y * i, 0.02)

# Clean-up work after the program has been completed
except KeyboardInterrupt:
    led_red.close()
    led_green.close()

This LED module contains two LEDs in the colors red and green, which are connected to each other via a common cathode. This means that both LEDs share the same negative connection, which simplifies the circuit. By controlling the individual LEDs, you can generate different color signals to indicate operating states or warnings, for example. The compact design and easy integration make this module ideal for a variety of applications where colour visualization is required, such as in control systems, displays or decorative projects.

Technical data
Forward voltage 2.0 - 2.5 V
Forward current 20 mA

Series resistors:

Depending on the input voltage, series resistors are required.

Input voltage Series resistor
3.3 V [Red] 120 Ω
3,3 V [Green] 120 Ω
5 V [Red] 220 Ω
5 V [Green] 220 Ω

Pin assignment


Micro:Bit Sensor
Pin 1 LED GREEN
Pin 2 LED RED
GND GND

Code example

	
		input.onButtonPressed(Button.A, function () {
		    pins.digitalWritePin(DigitalPin.P2, 1)
		    pins.digitalWritePin(DigitalPin.P1, 0)
		})
		input.onButtonPressed(Button.B, function () {
		    pins.digitalWritePin(DigitalPin.P1, 1)
		    pins.digitalWritePin(DigitalPin.P2, 0)
		})
	

Sample program download

microbit-KY-029.zip

This LED module contains two LEDs in the colors red and green, which are connected to each other via a common cathode. This means that both LEDs share the same negative connection, which simplifies the circuit. By controlling the individual LEDs, you can generate different color signals to indicate operating states or warnings, for example. The compact design and easy integration make this module ideal for a variety of applications where colour visualization is required, such as in control systems, displays or decorative projects.

Technical data
Forward voltage 2.0 - 2.5 V
Forward current 20 mA

Series resistors:

Depending on the input voltage, series resistors are required.

Input voltage Series resistor
3.3 V 120 Ω
5 V 220 Ω

Pin assignment


Raspberry Pi Pico Sensor
GPIO27 LED Red
GPIO28 LED Green
GND GND

1. Code example: ON/OFF

This code example shows how the integrated LEDs can be changed alternately, every 3 seconds, by means of a definable output pin.

To load the following code example onto your Pico, we recommend using the Thonny IDE. All you have to do first is go to Run > Configure interpreter ... > Interpreter > Which kind of interpreter should Thonny use for running your code? and select MicroPython (Raspberry Pi Pico).

Now copy the code below into your IDE and click on Run.

# Load libraries
from machine import Pin, PWM
from time import sleep

# Initialization of GPIO27 and GPIO28 as output
green_led = Pin(28, Pin.OUT)
red_led = Pin(27, Pin.OUT)
    
while True:
    # LED lights up in individual colors
    green_led.value(1)
    red_led.value(0)
    sleep(3)
    green_led.value(0)
    red_led.value(1)
    sleep(3)
    green_led.value(0)
    red_led.value(0)
    sleep(3)
    # LED lights up with both colors
    green_led.value(1)
    red_led.value(1)
    sleep(3)
    green_led.value(0)
    red_led.value(0)
    sleep(3)

2. Code example: PWM

By means of pulse width modulation [PWM], the brightness of an LED can be regulated - in this process, the LED is switched on and off at specific time intervals, with the ratio of the switch-on and switch-off time corresponding to a relative brightness. Due to the inertia of human vision, human eyes interpret such on/off behavior as a change in brightness. More information on this topic can be found in this article from mikrokontroller.net.

In this module several LEDs are integrated - by superimposing different brightness levels different colors can be created. This is shown in the following code example.

To load the following code example onto your Pico, we recommend using the Thonny IDE. All you have to do first is go to Run > Configure interpreter ... > Interpreter > Which kind of interpreter should Thonny use for running your code? and select MicroPython (Raspberry Pi Pico).

Now copy the code below into your IDE and click on Run.

# Load libraries
import machine
import math

# Initialization of GPIO27 and GPIO28 as PWM pin
ledRed = machine.PWM(machine.Pin(27))
ledRed.freq(1000)
ledGreen = machine.PWM(machine.Pin(28))
ledGreen.freq(1000)

# Definition of a 2 digit list
RBG = [0,0]

# Function: Color space calculation for red and green and
# Green is 90° offset to red
def sinColour(number):
    a = (math.sin(math.radians(number))+1)*32768
    c = (math.sin(math.radians(number+90))+1)*32768
    RBG = (int(a),int(c))
    return RBG

# Infinite loop where the color value for all two colors is shifted by 0.01 again and again
a = 0
while True:
    RBG = sinColour(a)
    a = a + 0.01
    if a == 360:
        a = 0
    ledRed.duty_u16(RBG[0])
    ledGreen.duty_u16(RBG[1])