// RGB LED control with Potentiometers using Arduino UNO
const int pinR = 3; // Red channel (PWM pin)
const int pinG = 5; // Green channel (PWM pin)
const int pinB = 6; // Blue channel (PWM pin)
const int potR = A0; // Potentiometer for Red
const int potG = A1; // Potentiometer for Green
const int potB = A2; // Potentiometer for Blue
void setup() {
pinMode(pinR, OUTPUT);
pinMode(pinG, OUTPUT);
pinMode(pinB, OUTPUT);
pinMode(potR, INPUT);
pinMode(potG, INPUT);
pinMode(potB, INPUT);
}
int readPot(int pin) {
return map(analogRead(pin), 0, 1023, 0, 255); // Convert analog value to PWM range
}
void loop() {
analogWrite(pinR, readPot(potR)); // Set red color brightness
analogWrite(pinG, readPot(potG)); // Set green color brightness
analogWrite(pinB, readPot(potB)); // Set blue color brightness
}