RGB LED with a single Potentiometer

Hello everyone,

Im having some trouble figuring out a logic problem ;)

I can easily contorl a RGB LED with 3 potentiometers. Each pot controls one of the color with a value between 1-255.

However, im not sure how i could make a RGB LED cycle thru all the colors using a single Potentiometer. It would be even better if i didn't have to use a arduino.

The goal is to make a RGB Reading Lamp. So the less components the better. If i have to use an arduino ill probably add some nifty sensors, like Light sensor and proximity sensor.

Thank you!

This project (Project 14) uses a rotary encoder rather than a pot to set the color.

http://www.arduinoevilgenius.com/projects

If you go to the downloads tab, you can get a zip with all the sketches in it.

If you want one pot to manage three diodes, then you'd somehow need three different current values - a problem.

If you use the Arduino, then you're actually using the pot value to display one of the possible 256 x 256 x 256 (or 16,777,216) combination of the colors (in reality, short and long pulses to make the LEDs dim or bright). Of course, that's 256 color RGB values - you're not actually limited to how close you want each shade to be. Since the pot comes in with 0-1023 as allowable values, you're converting it into three ranges.

As a simple example, use this:

long i=AnalogRead(/* your pin */);
int r=(i>>7)&0x7; // 0-7 for red
int g=(i>>3)&0xF; // 0-15 for green
int b=i&0x7; // 0-7 for blue

Of course, as you turn the dial, blues would change much more often than reds...

It would be difficult to make all colors available with a single pot. But if I'm following the gist of your question, it sounds like you want a pot that varies hue in a HSI color model (keeping saturation and intensity constant, likely 100%). Essentially just moving around the outside edge of color wheel. Is that what you are hoping to do?

Do a google search or check out wikipedia for further info on converting between RGB and HSI color-space. http://en.wikipedia.org/wiki/HSL_and_HSV