You will need
  • - Arduino;
  • - RGB led;
  • - 3 resistors at 220 Ohm;
  • - connecting wires;
  • - development Board;
  • computer.
Instruction
1
RGB LEDs are of two types: common anode ("plus") and common cathode ("minus"). The figure shows schematic diagrams of these two types of LEDs. Long leg of led is always the total output power. Separately is the output of the red led (R), green (G) and blue (B) are located on the other side of the anode, as shown in the figure. In this article we will discuss the connection of RGB LEDs with a common anode and a common cathode.
The RGB led is common cathode and common anode
2
Wiring diagram for RGB led common anode shown. Anode connected to "+5V" on the Arduino, the other three output to any digital pins.
Please note that we connect each of the LEDs through your resistor and do not use one common. It is desirable to do so, because each led has its efficiency. And if you connect them all through one resistor, the LEDs will glow with different brightness.
Wiring diagram for RGB led common anode for Arduino
3
Rewrite a classic sketch "blink". We will enable and disable each of the three colors. Please note that the led will light up when we served the low level (LOW) on the corresponding output from the Arduino.
Sketch blinking RGB led
4
View in action at the flashing RGB LEDs. The led light turns lit in red, green and blue colors. Each color is illuminated for 1 second and then turns off for 2 seconds, and starts the following one.
You can light each channel separately, all at the same time, then the color will change.
Flashing RGB led in action
5
If you use a RGB led with common cathode, you connect the longer pin of the led to the Arduino GND, and the channels R, G and B to digital ports of the Arduino. It should be remembered that the LEDs light up when applying to the channels R, G, B high level (HIGH), in contrast to the led common anode.
If you do not change the above sketch, each led color, in this case, will light for 2 seconds and the pause between them will be 1 second.
Wiring diagram for RGB led common cathode for Arduino