Pages: [1]   Go Down
Author Topic: Series of three potentiometers on one analog input (es: led RGB)  (Read 785 times)
0 Members and 1 Guest are viewing this topic.
Italy
Offline Offline
Newbie
*
Karma: 0
Posts: 15
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi to all and tank you for any suggestion,
I have a question about advanced using of potentiometers, but I can use an example to explain better what I mean.
there are many solutions to control an RGB led with arduino and potentiometers.
something like these:
1) rgb led with single potentiometer: http://legwinskij.blogspot.com/2011/01/arduino-rgb-mixer-with-single.html
2) rgb led with 3 potentiometers: http://www.arduino.cc/playground/Main/RGBLEDPWM

My question is valid for this hack but also for many others..
There is a way to control simultaneously the three colors (RGB) with 3 potentiometers without a swicth (es:1) and only one analog input?

I would use 3 potentiometer, in series, that have different load on a single analog input so that the sum of their values would be useful to generate an unic number for decoding rgb different amount.
To explain better the idea look this image:


in this case (i don't how to realize it), I should have a single value (es: 195) that would be enough to set up the three values of RGB led.
(in the example 195 => 1 for Blue(lowest intensity), 9 for green (max intensity) and 5 for red (medium intensity)

could someone help me to understand if this solution is possible and, in that case, some suggestion to realize it?

thanks a lot,
Marco.
Logged

Massachusetts, USA
Offline Offline
Tesla Member
***
Karma: 180
Posts: 8108
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I don't think that what you want to do is possible with pots.  It would be possible with switched resistors that have discrete values.

You could eliminate the momentary switch and use a single pot:
Code:
unsigned color = analogRead(potPin);  // Read 10-bit value
byte Red    = (color & 0b0000000111) << 5; // 3 bits (8 levels) of Red
byte Green = (color & 0b0001111000) << 1; // 4 bits (16 levels) of Green
byte Blue   = (color & 0b1110000000) >> 2; // 3 bits (8 levels) of Blue
analogWrite(redPin, RED);
analogWrite(greenPin, Green);
analogWtite(bluePin, Blue);
Logged

Send Bitcoin tips to: 1L3CTDoTgrXNA5WyF77uWqt4gUdye9mezN
Send Litecoin tips to : LVtpaq6JgJAZwvnVq3ftVeHafWkcpmuR1e

United Kingdom
Offline Offline
Tesla Member
***
Karma: 220
Posts: 6587
Hofstadter's Law: It always takes longer than you expect, even when you take into account Hofstadter's Law.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

I agree, it's not possible to read 3 pots and work out how far each one is rotated using with a single pin. If it's specifically analog pins you are short of, you could use 1 analog pin and 3 digital pins (or 2 at a push) to achieve this.
Logged

Formal verification of safety-critical software, software development, and electronic design and prototyping. See http://www.eschertech.com. Please do not ask for unpaid help via PM, use the forum.

Offline Offline
God Member
*****
Karma: 3
Posts: 813
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I would recommend three transistors that each tie the potentiometer moving pin to the same analog input. Drive the three transistors from three digital pins (or two, with a binary-to-selector decoder :-).
The sketch would read one value, and then switch which one is active, and then do anything else, each time through the loop. This gives the single analog input some time to stabilize before the next input is read.
Logged

Central MN, USA
Offline Offline
Tesla Member
***
Karma: 65
Posts: 6944
Phi_prompt, phi_interfaces, phi-2 shields, phi-panels
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

If you have digital pins available, use rotary encoder with a clickable shaft. You rotate to set one color, click the shaft to go to the next color.
Logged


Pages: [1]   Go Up
Jump to: