RGB Lamp with Arduino UNO
& 3 Potentiometers
Mix millions of colors by controlling Red, Green, and Blue brightness independently using analog knobs and PWM output.
Components Required
Circuit Diagram
255 - value before writing.
Pin Connection Reference
| Component | Component Pin | Arduino Pin |
|---|---|---|
| Red Potentiometer | Left → GND, Right → 5V | Wiper → A0 |
| Green Potentiometer | Left → GND, Right → 5V | Wiper → A1 |
| Blue Potentiometer | Left → GND, Right → 5V | Wiper → A2 |
| RGB LED — Red | Via 220Ω resistor | PWM Pin 9 |
| RGB LED — Green | Via 220Ω resistor | PWM Pin 10 |
| RGB LED — Blue | Via 220Ω resistor | PWM Pin 11 |
| RGB LED — Cathode | Common cathode | GND |
Step-by-Step Build Guide
1
Place the Arduino UNO on the breadboard
Position the Arduino above or beside your breadboard so power rails are accessible. Connect the USB cable to power and communicate.
2
Insert the three 10kΩ potentiometers
Place each pot straddling the breadboard center gap. They'll label as Red (A0), Green (A1), and Blue (A2) pots.
3
Wire each potentiometer's power and GND
Connect the left outer pin of each pot to GND rail. Connect the right outer pin of each pot to the 5V rail. Use the breadboard power rails for a clean layout.
4
Connect the wiper pins to analog inputs
Wire the middle (wiper) pin of the Red pot → A0, Green pot → A1, Blue pot → A2 on the Arduino.
5
Insert the RGB LED into the breadboard
The longest leg is the common cathode — connect it to GND. The other three legs are R, G, B (check your datasheet for order).
6
Add the 220Ω current-limiting resistors
Place one 220Ω resistor in series with each of the Red, Green, and Blue LED pins. This prevents the LED from drawing too much current.
7
Connect LED pins to PWM outputs
Red pin (via resistor) → Pin 9 | Green pin (via resistor) → Pin 10 | Blue pin (via resistor) → Pin 11.
8
Upload the Arduino sketch
Open Arduino IDE, paste the code below, select your board (Arduino UNO) and the correct COM port, then click Upload.
9
Test and mix colors!
Rotate the three knobs. The LED should change color in real-time. Turn all fully clockwise to get white; all counterclockwise for off (black).
Arduino Sketch
// RGB Lamp — MakeMindz.com
// Control RGB LED brightness with 3 potentiometers
int redPin = 9;
int greenPin = 10;
int bluePin = 11;
int redPot = A0;
int greenPot = A1;
int bluePot = A2;
void setup() {
pinMode(redPin, OUTPUT);
pinMode(greenPin, OUTPUT);
pinMode(bluePin, OUTPUT);
}
void loop() {
// Read 10-bit analog value (0–1023) from each knob
int redValue = analogRead(redPot);
int greenValue = analogRead(greenPot);
int blueValue = analogRead(bluePot);
// Scale to 8-bit PWM range (0–255)
redValue = map(redValue, 0, 1023, 0, 255);
greenValue = map(greenValue, 0, 1023, 0, 255);
blueValue = map(blueValue, 0, 1023, 0, 255);
// Write PWM to LED channels
analogWrite(redPin, redValue);
analogWrite(greenPin, greenValue);
analogWrite(bluePin, blueValue);
}
🔬 Try it Before You Build
Test the full circuit in Tinkercad — no hardware needed. Spin the virtual knobs to see color mixing in action.
▶ Open Simulation
RGB Color Mixing Reference
Set your potentiometers to these positions to produce the primary and secondary colors:
🔴 Red only
R=255 G=0 B=0
🟢 Green only
R=0 G=255 B=0
🔵 Blue only
R=0 G=0 B=255
🟡 Yellow
R=255 G=255 B=0
🟣 Magenta
R=255 G=0 B=255
🩵 Cyan
R=0 G=255 B=255
⚪ White
R=255 G=255 B=255
⚫ Off
R=0 G=0 B=0
What You'll Learn
✅ Reading analog signals with analogRead()
✅ Generating PWM signals with analogWrite()
✅ Scaling values with map() function
✅ RGB additive color mixing theory
✅ Current-limiting resistor placement
✅ Basic breadboard circuit design
Take It Further
Auto color fade
Cycle through hues automatically using a timer loop
Sound-reactive lamp
Use a microphone module to react to music beats
Bluetooth control
Replace pots with HC-05 and a smartphone app
Color presets
Add push-buttons to snap to saved colors instantly
OLED display
Show live R/G/B values on a 128×64 OLED screen
Master brightness
Add a 4th pot to scale all channels simultaneously
More Arduino Projects on MakeMindz
Step-by-Step Build Guide
Place the Arduino UNO on the breadboard
Position the Arduino above or beside your breadboard so power rails are accessible. Connect the USB cable to power and communicate.
Insert the three 10kΩ potentiometers
Place each pot straddling the breadboard center gap. They'll label as Red (A0), Green (A1), and Blue (A2) pots.
Wire each potentiometer's power and GND
Connect the left outer pin of each pot to GND rail. Connect the right outer pin of each pot to the 5V rail. Use the breadboard power rails for a clean layout.
Connect the wiper pins to analog inputs
Wire the middle (wiper) pin of the Red pot → A0, Green pot → A1, Blue pot → A2 on the Arduino.
Insert the RGB LED into the breadboard
The longest leg is the common cathode — connect it to GND. The other three legs are R, G, B (check your datasheet for order).
Add the 220Ω current-limiting resistors
Place one 220Ω resistor in series with each of the Red, Green, and Blue LED pins. This prevents the LED from drawing too much current.
Connect LED pins to PWM outputs
Red pin (via resistor) → Pin 9 | Green pin (via resistor) → Pin 10 | Blue pin (via resistor) → Pin 11.
Upload the Arduino sketch
Open Arduino IDE, paste the code below, select your board (Arduino UNO) and the correct COM port, then click Upload.
Test and mix colors!
Rotate the three knobs. The LED should change color in real-time. Turn all fully clockwise to get white; all counterclockwise for off (black).
Arduino Sketch
// RGB Lamp — MakeMindz.com // Control RGB LED brightness with 3 potentiometers int redPin = 9; int greenPin = 10; int bluePin = 11; int redPot = A0; int greenPot = A1; int bluePot = A2; void setup() { pinMode(redPin, OUTPUT); pinMode(greenPin, OUTPUT); pinMode(bluePin, OUTPUT); } void loop() { // Read 10-bit analog value (0–1023) from each knob int redValue = analogRead(redPot); int greenValue = analogRead(greenPot); int blueValue = analogRead(bluePot); // Scale to 8-bit PWM range (0–255) redValue = map(redValue, 0, 1023, 0, 255); greenValue = map(greenValue, 0, 1023, 0, 255); blueValue = map(blueValue, 0, 1023, 0, 255); // Write PWM to LED channels analogWrite(redPin, redValue); analogWrite(greenPin, greenValue); analogWrite(bluePin, blueValue); }
🔬 Try it Before You Build
Test the full circuit in Tinkercad — no hardware needed. Spin the virtual knobs to see color mixing in action.
RGB Color Mixing Reference
Set your potentiometers to these positions to produce the primary and secondary colors:
R=255 G=0 B=0
R=0 G=255 B=0
R=0 G=0 B=255
R=255 G=255 B=0
R=255 G=0 B=255
R=0 G=255 B=255
R=255 G=255 B=255
R=0 G=0 B=0
What You'll Learn
analogRead()analogWrite()map() functionTake It Further
Cycle through hues automatically using a timer loop
Use a microphone module to react to music beats
Replace pots with HC-05 and a smartphone app
Add push-buttons to snap to saved colors instantly
Show live R/G/B values on a 128×64 OLED screen
Add a 4th pot to scale all channels simultaneously

Comments
Post a Comment