Fiverr gig
$15 — I will help you with your project and simulate it for you
Hire me
🌐 IoT Projects

How to Control RGB LED with Arduino

EmbedLab TeamDecember 30, 20244 min read
How to Control RGB LED with Arduino
  • Description: Control the color of an RGB LED using three potentiometers for red, green, and blue components.
  • Requirements: RGB LED, 3 potentiometers, resistors.
  • Learning Points: PWM (analogWrite), RGB color blending.

Schematic:
Schematic



Code:
// File: RGB_LED_Color_Mixer.ino

// Define RGB LED pins
const int redPin = 11;    // Red LED (PWM)
const int greenPin = 10; // Green LED (PWM)
const int bluePin = 9;  // Blue LED (PWM)

// Define potentiometer pins
const int redPot = A0;   // Red potentiometer
const int greenPot = A1; // Green potentiometer
const int bluePot = A2;  // Blue potentiometer

void setup() {
  // Set RGB pins as outputs
  pinMode(redPin, OUTPUT);
  pinMode(greenPin, OUTPUT);
  pinMode(bluePin, OUTPUT);

  // Start Serial Monitor for debugging (optional)
  Serial.begin(9600);
}

void loop() {
  // Read potentiometer values (0 to 1023)
  int redValue = analogRead(redPot);
  int greenValue = analogRead(greenPot);
  int blueValue = analogRead(bluePot);

  // Map potentiometer values (0 to 255) for PWM
  redValue = map(redValue, 0, 1023, 0, 255);
  greenValue = map(greenValue, 0, 1023, 0, 255);
  blueValue = map(blueValue, 0, 1023, 0, 255);

  // Apply PWM values to RGB LED
  analogWrite(redPin, redValue);
  analogWrite(greenPin, greenValue);
  analogWrite(bluePin, blueValue);

  // Debugging: Print values to Serial Monitor
  Serial.print("Red: ");
  Serial.print(redValue);
  Serial.print(" | Green: ");
  Serial.print(greenValue);
  Serial.print(" | Blue: ");
  Serial.println(blueValue);

  delay(50); // Small delay for stability
}


Colors:

white:
White


Blue:
Blue


Green:
Green


Red:
Red



Black:

Black



Blend1:

Color Blend 1




Blend2:


Color Blend 2



How It Works

  1. Potentiometer Values:

    • Each potentiometer adjusts a single color component (Red, Green, or Blue).
    • The potentiometer’s position determines an analog value between 0 and 1023.
  2. Mapping Values:

    • The analog input values (0–1023) are mapped to the PWM range (0–255) using map().
  3. PWM Output:

    • analogWrite() is used to set the brightness of each color component.
  4. Color Mixing:

    • By combining different brightness levels of Red, Green, and Blue, you can create millions of colors.
Or just Download the Project here: 
https://drive.google.com/file/d/1lMa3po8TXfzRmLPR1ty03hLwuU_fmvQc/view?usp=drive_link
And watch my youtube channel, for more tutorials!

ET

EmbedLab Team

Embedded systems engineer and educator. Writes weekly tutorials at EmbedLab to help beginners ship real hardware.

Related projects

How to Control LEDs Using Blynk and Arduino Uno: A Complete Guide
🌐 IoT Projects

How to Control LEDs Using Blynk and Arduino Uno: A Complete Guide

  How to Control LEDs Using Blynk and Arduino Uno: A Complete Guide Controlling LEDs remotely using Blynk and an Arduino Uno is a simple yet powerful project for IoT (Internet of Things) enthusia

Apr 4 4 min
Blynk IoT app controlling Arduino UNO and ESP32 over Wi-Fi
🌐 IoT Projects

Blynk IoT with Arduino UNO & ESP32 — Free Arduino IDE, Library & App Tutorial

Complete Blynk IoT tutorial for Arduino UNO and ESP32 Arduino: install the Arduino IDE, add the Blynk Arduino library, wire LEDs, LCD and sensors, and control everything from the Blynk app over Wi-Fi — a free, beginner-friendly Arduino IoT project.

Nov 19 6 min
Arduino UNO and ESP32 Blink IoT project with Blynk app
🌐 IoT Projects

Arduino UNO Blink IoT Guide — ESP32 Arduino, Blynk App & Arduino IDE Code

Complete Arduino UNO Blink IoT guide using ESP32 Arduino and the Blynk app: free Arduino IDE code, Arduino library and LED wiring — the easiest Arduino IoT project for beginners to download and try online.

Oct 27 9 min
Remote control of 2 LED with Arduino.
🌐 IoT Projects

Remote control of 2 LED with Arduino.

  How to Control LEDs Using Blynk and Arduino Uno: A Complete Guide Controlling LEDs remotely using Blynk and an Arduino Uno is a simple yet powerful project for IoT (Internet of Things) enthusia

Mar 31 4 min
Top 5 IoT projects with Arduino UNO and ESP32 — Blynk app, Wi-Fi and smart home
🌐 IoT Projects

Top 5 IoT Projects with Arduino UNO & ESP32 — Blynk, Wi-Fi & Smart Home Tutorials (2026)

The top 5 IoT projects every Arduino UNO and ESP32 maker should build in 2026 — Blynk IoT control, Wi-Fi blink, ESP-WROOM-32 dev board guide, ESP32 Proteus 8 simulation and an Arduino smart home parking system. Each pick links to the full tutorial with free Arduino IDE code, library and wiring.

May 30 8 min
Browse all 50+ projects