RGB LED color control using 3 potentiometers
RGB LED color control using 3 potentiometers
– 9
Problem Statement:
Components Required:
• Arduino Board (UNO, Mega, etc.)
• RGB LED
• 3 x Potentiometers (10kΩ)
• 3 x 220Ω Resistors
• Breadboard
• Jumper Wires
• Arduino IDE
Circuit Connections:
#define RED_PIN 9
#define GREEN_PIN 10
#define BLUE_PIN 11
#define POT_RED A0
#define POT_GREEN A1
#define POT_BLUE A2
void setup() {
Serial.begin(9600);
pinMode(RED_PIN, OUTPUT);
pinMode(GREEN_PIN, OUTPUT);
pinMode(BLUE_PIN, OUTPUT);
}
void loop() {
int redValue = analogRead(POT_RED);
int greenValue = analogRead(POT_GREEN);
int blueValue = analogRead(POT_BLUE);
analogWrite(RED_PIN, redValue);
analogWrite(GREEN_PIN, greenValue);
analogWrite(BLUE_PIN, blueValue);
Serial.print("Red: ");
Serial.println(redValue);
Serial.print("Green: ");
Serial.println(greenValue);
Serial.print("Blue: ");
Serial.println(blueValue);
delay(100);
}
Output:
1. When you turn the potentiometers, the color of the RGB LED
changes based on the combined Red, Green, and Blue intensity
values.
2. The Serial Monitor displays the current RGB values in the
format:
• Red: 120
• Green: 200
• Blue: 45
3. The LED color dynamically changes as you adjust the
potentiometers, creating a range of color combinations.