Diffused 10 mm RGB LED on circuit board

FunduinoPublished on

Rot, Grün und Blau einzeln ansteuern

Eine RGB-LED enthält drei Leuchtdioden in einem Gehäuse: Rot, Grün und Blau.

In dieser Anleitung schließt du die RGB-LED auf ihrer Platine an drei digitale Pins an und lässt die Farben nacheinander aufleuchten.

The 10 mm-diameter RGB LED on its circuit board

The RGB LED

RGB stands for the three primary colors red, green, and blue. The RGB LED contains a separate element for each color, each connected to its own digital pin.

You can find LEDs like these, for example:

  • in machines as status indicators - red for a fault, green for normal operation
  • at home as LED strips for decoration or indirect lighting
The 10 mm-diameter RGB LED on its circuit board

Connection to the Arduino

  • R to pin 5
  • G to pin 6
  • B to pin 7
  • GND to GND
Connect the RGB board: R to pin 5, G to pin 6, B to pin 7, GND to GND

The program

The sketch turns on the three colors one after another for one second each. Since the colors are only switched on and off here, regular digital pins are sufficient. To mix colors, use PWM-capable pins and analogWrite().

Red, green, and blue in sequence.
// Farbe rot an Pin 5
int LEDrot = 5;
// Farbe grün an Pin 6
int LEDgruen = 6;
// Farbe blau an Pin 7
int LEDblau = 7;
void setup()
{
  // LEDs als Ausgang setzen
  pinMode(LEDrot, OUTPUT);
  pinMode(LEDgruen, OUTPUT);
  pinMode(LEDblau, OUTPUT);
}
void loop()
{
  // rotes Element für 1 Sekunde einschalten
  digitalWrite(LEDrot, HIGH);
  delay(1000);
  digitalWrite(LEDrot, LOW);
  // grünes Element für 1 Sekunde einschalten
  digitalWrite(LEDgruen, HIGH);
  delay(1000);
  digitalWrite(LEDgruen, LOW);
  // blaues Element für 1 Sekunde einschalten
  digitalWrite(LEDblau, HIGH);
  delay(1000);
  digitalWrite(LEDblau, LOW);
}
Rate the instructions

Comments

Ask a question or share an experience

Contact us if something doesn’t work. Please include your board and the error message.

We review every comment before publication. Your email address remains with us.