
Hello guys, Welcome back to my SriTu Hobby blog. Today we will learn how to control an RGB LED bulb. Let us first see what an RGB LED bulb is. An RGB LED Bulb is a diode made up of three colors: red, green, and blue. We can get the desired color by adding or subtracting the three colors here. Also, we can light these three colors separately. We can usually see two pins of an LED bulb, but in this RGB LED bulb, we can see four pins. Here we can identify three pins as the anode terminal of the three colors and the other pin as the cathode terminal of the three colors. In particular, the cathode pin is longer than the other pins.
(adsbygoogle = window.adsbygoogle || []).push({});We will now test this RGB LED bulb using an Arduino board. For this, we need three Potentiometers in addition to the RGB bulb. The potentiometer is a variable resistor. Here the resistance value is changed by twisting the knob. Through these, we can increase or decrease the brightness of the three diodes in the RGB LED bulb.
Well now let’s see what components are needed for this project. You can easily buy these components using the links below.
- Arduino UNO board x 1 — Amazon / Our Store
- RGB LED bulb x 1 — Amazon / Banggood
- Potentiometer x 3 — Amazon / Our Store
- 180-ohm Resistor x 3 — Amazon / Our Store
- Breadboard x 1 — Amazon / Our Store
- Jumper wires — Amazon / Our Store
Disclosure: These Amazon links are Affiliate links. As an Amazon Associate, I earn from qualifying purchases.
Ok, let’s do this project step by step.
Step 1






Step 2

Step 3
/*RGB LED bulb PWM with Arduino.
Serial monitor readings.
created by the SriTu Tech team.
Read the code below and use it for any of your creation
*/
#define red 3
#define green 5
#define blue 6
void setup() {
Serial.begin(9600);
pinMode(red, OUTPUT);
pinMode(green, OUTPUT);
pinMode(blue, OUTPUT);
}
void loop() {
int p1 = analogRead(A0);
int p2 = analogRead(A1);
int p3 = analogRead(A2);
p1 = map(p1, 0, 1023, 0, 255);
analogWrite(red, p1);
Serial.println(p1);
p2 = map(p2, 0, 1023, 0, 255);
analogWrite(green, p2);
Serial.println(p2);
p3 = map(p3, 0, 1023, 0, 255);
analogWrite(blue, p3);
Serial.println(p3);
}
Code explanation
Step 4



RGB LED bulb control | Step by step instructions