In this tutorial, I will show you what an RGB LED is and how it works.
An RGB LED is a combination of 3 LEDs: red, green, and blue. These three colors can make any color. By varying supplied voltage to the RGB LEDs, different colors are formed.
An RGB LED has 4-pin interfaces. 3 pins are for red, blue, and green. There is a common pins for all three LEDs.
An RGB LED can be two types: Common Anode: -Anode (+) pin is common Common Cathode: -(Cathode-/GND) pin is common
Hardware Required- NodeMCU
- Breadboard
- RGB LED
- Resistor 1k
- Jumper Male to male
Schematic of circuit
Common Anode:-Anode (+) pin is common. Layout of circuit
// Mechatronicslabrpi.blogspot.com Tutorial
// Hardware: NodeMCU
int RED = 5;
int GREEN = 4;
int BLUE = 0;
void setup() {
pinMode(RED, OUTPUT);
pinMode(GREEN, OUTPUT);
pinMode(BLUE, OUTPUT);
}
void loop() {
digitalWrite(RED,HIGH);
digitalWrite(GREEN,LOW);
digitalWrite(BLUE,LOW);
delay (1000);
digitalWrite(RED,LOW);
digitalWrite(GREEN,HIGH);
digitalWrite(BLUE,LOW);
delay (1000);
digitalWrite(RED,LOW);
digitalWrite(GREEN,LOW);
digitalWrite(BLUE,HIGH);
delay (1000);
}
Click here to download full file.
Video
Comments