Full Color Mixer with 2 Control Knobs

Submitted by mschiff on Mon, 02/18/2013 - 23:39
mschiff's picture


For this assignment, I started off with a single potentiometer. I realized that you could not achieve any different color mix given only the single control value. The immediate solution was to add two more potentiometers. This way you can control the brightness of each color individually, allowing full movement in the RGB space. I wanted to play with the idea of constraint, so I decided to limit myself to two potentiometers.  I was able to achieve full mobility in the color space by using one of the potentiometers to select the mode of interaction (which LED you would be interacting with) and the other potentiometer raised and lowered the current LEDs brightness.

Though this may be slightly less intuitive then a mode-less interaction, I found the challenge of limiting the available resources interesting


  • breadboard x1
  • potentiometer x2
  • arduino x1
  • LEDs x3
  • resistors x3
  • jumper wire


//constant pin definitions
const int modeKnob = 0;  //used to set mode
const int valKnob = 1;   //used to set value
//a pwm compatible pin for each LED
const int blue = 9;
const int red = 10;
const int green = 11;

//initially all the LEDs are set to value=0
int redVal = 0;
int greenVal = 0;
int blueVal = 0;

void setup() {
  Serial.begin(9600); //just for debugging output

void loop() {
  //set the mode based on the position of the first knob 
  int mode = map(analogRead(modeKnob), 0, 1023, 0, 2);
  //set the value based on the position of the second knob
  int value = map(analogRead(valKnob), 0, 1023, 0, 255);
  //update LED values depending on which mode we are in
  Serial.println(mode);  //so we can verify mode over serial
  if (mode == 0) { redVal = value; }
  else if (mode == 1) { greenVal = value; }
  else { blueVal = value; }
  //write to the actual LEDs
  analogWrite(red, redVal);
  analogWrite(green, greenVal);
  analogWrite(blue, blueVal);


Your rating: None
Drupal theme by Kiwi Themes.