Arduino Projects Ideas - RGB LED Color Mixer

 Arduino Projects Ideas - RGB LED Color Mixer

Components:
RGB LED (common cathode)
3× 220Ω resistors
3 Potentiometers
Arduino UNO

Wiring:
Red pin → A0
Green pin → A1
Blue pin → A2
Common cathode → GND
Potentiometers connected to A0, A1, A2 respectively

Code:

void setup() {
  pinMode(9, OUTPUT); // Red
  pinMode(10, OUTPUT); // Green
  pinMode(11, OUTPUT); // Blue
}
void loop() {
  int r = analogRead(A0) / 4;
  int g = analogRead(A1) / 4;
  int b = analogRead(A2) / 4;
  analogWrite(9, r);
  analogWrite(10, g);
  analogWrite(11, b);
}