0% found this document useful (0 votes)
1 views

RGB LED color control using 3 potentiometers

This document outlines an Arduino experiment to control the intensity of an RGB LED using three potentiometers. It details the required components, circuit connections, and provides the Arduino code to read the potentiometer values and adjust the LED colors accordingly. The output includes real-time RGB values displayed on the Serial Monitor as the potentiometers are adjusted.

Uploaded by

prathameshkate15
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
1 views

RGB LED color control using 3 potentiometers

This document outlines an Arduino experiment to control the intensity of an RGB LED using three potentiometers. It details the required components, circuit connections, and provides the Arduino code to read the potentiometer values and adjust the LED colors accordingly. The output includes real-time RGB values displayed on the Serial Monitor as the potentiometers are adjusted.

Uploaded by

prathameshkate15
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

EXPERIMENT NO.

– 9

Problem Statement:

Write an Arduino program that:


• Uses 3 potentiometers to control the intensity of Red, Green, and
Blue colors of an RGB LED.
• Reads the analog values from the potentiometers and adjusts the
brightness of each color accordingly.

Components Required:
• Arduino Board (UNO, Mega, etc.)
• RGB LED
• 3 x Potentiometers (10kΩ)
• 3 x 220Ω Resistors
• Breadboard
• Jumper Wires
• Arduino IDE

Circuit Connections:

1. RGB LED Connections


o Red Pin → Digital Pin 9 (via 220Ω resistor)
o Green Pin → Digital Pin 10 (via 220Ω resistor)
o Blue Pin → Digital Pin 11 (via 220Ω resistor)
o Common Cathode → GND
2. Potentiometer Connections
o Potentiometer 1 (Red):
▪ VCC → 5V
▪ GND → GND
▪ Output Pin → A0
o Potentiometer 2 (Green):
▪ VCC → 5V
▪ GND → GND
▪ Output Pin → A1
o Potentiometer 3 (Blue):
• VCC → 5V
• GND → GND
• Output Pin → A2
Arduino Code :

#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);

redValue = map(redValue, 0, 1023, 0, 255);


greenValue = map(greenValue, 0, 1023, 0, 255);
blueValue = map(blueValue, 0, 1023, 0, 255);

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.

You might also like