RGB LAMP CONTROL USING ARDUINO AND POTENTIOMETER

RGB Lamp Using Arduino UNO & 3 Potentiometers | MakeMindz
⚡ Intermediate Project

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.

⏱ ~45 min
🧩 7 components
📟 Arduino UNO
🎓 PWM + Analog
🛒

Components Required

×1 Arduino UNO
×1 RGB LED (Common Cathode)
×3 10kΩ Potentiometers
×3 220Ω Resistors
×1 Breadboard
Jumper Wires
×1 USB Cable / 5V Supply
📐

Circuit Diagram

RGB LAMP — CIRCUIT DIAGRAM ARDUINO UNO A0 A1 A2 GND 5V ~9 ~10 ~11 GND POT RED GND OUT 5V POT GRN GND OUT 5V POT BLU GND OUT 5V RGB LED R GND G B 220Ω 220Ω 220Ω LEGEND Red channel Green channel Blue channel GND 5V power
💡 Common Anode LED? Connect the common pin to 5V instead of GND, and invert PWM values in the sketch: use 255 - value before writing.
🔌

Pin Connection Reference

ComponentComponent PinArduino Pin
Red PotentiometerLeft → GND, Right → 5VWiper → A0
Green PotentiometerLeft → GND, Right → 5VWiper → A1
Blue PotentiometerLeft → GND, Right → 5VWiper → A2
RGB LED — RedVia 220Ω resistorPWM Pin 9
RGB LED — GreenVia 220Ω resistorPWM Pin 10
RGB LED — BlueVia 220Ω resistorPWM Pin 11
RGB LED — CathodeCommon cathodeGND


📋

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

Arduino C / .ino
// 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
📚