// Arduino RGB LED Color Mixer - ozandamci.com
const int redPin = 9;
const int greenPin = 10;
const int bluePin = 11;
const int redPot = A0;
const int greenPot = A1;
const int bluePot = A2;
void setup() {
pinMode(redPin, OUTPUT);
pinMode(greenPin, OUTPUT);
pinMode(bluePin, OUTPUT);
Serial.begin(9600);
}
void loop() {
// The potentiometers give 0–1023, the LED needs 0–255
int red = map(analogRead(redPot), 0, 1023, 0, 255);
int green = map(analogRead(greenPot), 0, 1023, 0, 255);
int blue = map(analogRead(bluePot), 0, 1023, 0, 255);
analogWrite(redPin, red);
analogWrite(greenPin, green);
analogWrite(bluePin, blue);
Serial.print("R: ");
Serial.print(red);
Serial.print(" G: ");
Serial.print(green);
Serial.print(" B: ");
Serial.println(blue);
delay(50);
}