Bicolor LEDs are cheap and quite popular as indicators of various things. 3 leg Here is Arduino 3 leg bicolor LED wiring and code to blink or fade. LEDs have color specific resistor values.
A bicolor LED is practically two LEDs with one common anode or cathode. Some have common positive terminal (anode) and some have common negative terminal (cathode). When different voltage is applied to different LEDs, they make a mixture and produce several thousands of colors.
We commonly use which has middle terminal negative terminal and side terminals are for positive connection for green/red like lights. It is possible make beautiful christmas light with them with easy code. Now, regarding the resistor. We need a multimeter for the work. We need a source voltage which is around 30mA of 3V (or 2V if 0V is applied) with 0.5V variation.
---
Here is datasheet of SMD bicolor LEDs (calculation will be closer) :
1 | https://www.kingbright-europe.de/wp-content/uploads/2013/08/KPB-2012SURKCGKCVer.2A.pdf |
Arduino 3 Leg Bicolor LED Wiring and Code
Wiring is easy. You’ll connect the middle leg of the bicolor LED with GND of Arduino. Rest one leg of the bicolor LED will be attached with a 220 Ohm resistor (from rough calculation) and connected to some digital pin of Arduino. The last and third leg of the bicolor LED also will be attached with a 220 Ohm resistor (from rough calculation) and connected to another digital pin of Arduino. So, unlike the 2 leg LEDs, you will have 2 pins to code for. You have to adust the resistor values for correct and equal amount of light from both of them (otherwise one color will appear to be dull, dim). There are also modules available for the bicolor LEDs. Wiring will be simillar like just bare bicolor LED :
Here is code :
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | // led1 and led2 are two legs of bicolor led int led1 = 13; int led2 = 12; void setup() { pinMode(led1, OUTPUT); pinMode(led2, OUTPUT); } void loop() { digitalWrite(led2, HIGH); delay(2000); digitalWrite(led2, LOW); delay(2000); digitalWrite(led1, HIGH); delay(2000); digitalWrite(led1, LOW); delay(2000); digitalWrite(led1, HIGH); digitalWrite(led2, HIGH); delay(2000); digitalWrite(led1, LOW); digitalWrite(led2, LOW); delay(2000); } |