This circuit is designed to control the color of two RGB LEDs using three potentiometers. The potentiometers adjust the red, green, and blue components of the LEDs, allowing for smooth color transitions. An Arduino Micro (Rev3) microcontroller reads the potentiometer values and adjusts the LED colors accordingly.
Potentiometer
RGB LED (Wokwi compatible)
Resistor
Arduino Micro (Rev3)
150 Ohms Resistor 1:
82 Ohms Resistor 1:
82 Ohms Resistor 2:
150 Ohms Resistor 2:
82 Ohms Resistor 3:
82 Ohms Resistor 4:
/*
* This Arduino Sketch reads values from three potentiometers and adjusts the
* color of two RGB LEDs accordingly. The potentiometers control the red, green,
* and blue components of the LEDs, allowing for smooth color transitions.
*/
const int potPin1 = A1; // Potentiometer 1 connected to A1
const int potPin2 = A2; // Potentiometer 2 connected to A2
const int potPin3 = A3; // Potentiometer 3 connected to A3
const int led1R = 10; // Red pin of RGB LED 1
const int led1G = 9; // Green pin of RGB LED 1
const int led1B = 8; // Blue pin of RGB LED 1
const int led2R = 6; // Red pin of RGB LED 2
const int led2G = 5; // Green pin of RGB LED 2
const int led2B = 4; // Blue pin of RGB LED 2
void setup() {
// Initialize LED pins as outputs
pinMode(led1R, OUTPUT);
pinMode(led1G, OUTPUT);
pinMode(led1B, OUTPUT);
pinMode(led2R, OUTPUT);
pinMode(led2G, OUTPUT);
pinMode(led2B, OUTPUT);
}
void loop() {
// Read potentiometer values
int potValue1 = analogRead(potPin1);
int potValue2 = analogRead(potPin2);
int potValue3 = analogRead(potPin3);
// Map potentiometer values to PWM range (0-255)
int redValue = map(potValue1, 0, 1023, 0, 255);
int greenValue = map(potValue2, 0, 1023, 0, 255);
int blueValue = map(potValue3, 0, 1023, 0, 255);
// Set LED colors
analogWrite(led1R, redValue);
analogWrite(led1G, greenValue);
analogWrite(led1B, blueValue);
analogWrite(led2R, redValue);
analogWrite(led2G, greenValue);
analogWrite(led2B, blueValue);
delay(10); // Small delay to smooth out the color transitions
}
void setup() {
// put your setup code here, to run once:
}
void loop() {
// put your main code here, to run repeatedly:
}
void setup() {
// put your setup code here, to run once:
}
void loop() {
// put your main code here, to run repeatedly:
}
void setup() {
// put your setup code here, to run once:
}
void loop() {
// put your main code here, to run repeatedly:
}
This documentation provides a comprehensive overview of the circuit, including a summary, component list, wiring details, and the code used in the microcontroller.