Author Options:

4 Potentiometers with Arduino? Answered

Hey, I'm not understanding something here. 
If I hook up a pot (left 9v, middle A0, right GND), I get a varying voltage into pin A0 on Arduino. Then Arduino converts this into whatever.
Well when I hooked up 4 potentiometers parallel to the same battery, and had them on pins A0-A3, none of the pots worked. Whenever I turned one pot, it would change the value for all the others (i was using serial monitor).

How do I correctly hook up four pots to Arduino?



Best Answer 5 years ago

Make sure to declare your outputs as outputs and your inputs as inputs!

I'm guessing since the values change when other pots move that you are reading disconnected pins (your code is reading from the wrong address)
It's probably also a bad idea to name a variable the same as a pin name (A1). You can skip saving the value of A1

int pot1 = analogRead(A0) * 10.0 / 1023.0;

Oh, that is what the problem is! Do I still need to put this in the setup?

pinMode(A0, INPUT);


I see, so once I changed the names I immediately got the expected results. Thanks!

Yep, if he's using pin name constants as variable, that's a problem. I'm surprised the compiler allows it...


5 years ago

If the POTs are connected as you say, it's probably a software problem related to reading the ADC...or an issue with variables and control structure...

Also-- DON'T use more than the max supply voltage for the Arduino on the ADC. 5V at the most. Feeding any of the I/O pins more than 5V is a bad idea...

You can scale external voltages down with fixed dividers, but a POT divider with 9 to 0V is asking for trouble.

Asking ? I'd guarantee it ;-) WELL above pin Vmax (6 I think)


If your input is fixed at 9V max, "prescale" it by adding another resistor in series with the POT (on the V+ side of the POT).

If the POT is 100K, add a 100K resistor. Now the voltage range on the wiper will be 1/2 the total, or 4.5V to 0V.

(if you add the resistor on the GND side of the POT, the wiper V range will be 9V to 4.5V.)

Hey thank you for telling me about that! I would have never figured that out!

You're welcome... Let's hope you haven't fried the I/O pins on your 'duino.

BTW, what POT values are you using? Remember that four parallel POTs sum to make a load that can effect power supply performance (four 1K pots equal a 250 ohm load). The ADC pins are really high impedance, so there is no penalty for using higher resistance POTS (four 500K Pots make a 125K load).

Ok slow down! Well, I got rid of the old pots I was using, and thankfully, I wasn't using the 9v for very long. Only a minute or two. Hopefully, it's not fried up. If so, well, radioshack, here I come :D.

Right now I just replaced my big pots with the smaller kind. They are each 10k, their markings say 103.
So what do you mean by they equal a less load? Load? ADC pins are really high independence?



The load is analogous to the amount of resistance (actually impedance, which is a fancy name for resistance to both AC and DC) placed on a circuit.

Actually, when describing a load, it's the inverse of resistance. I.E., 10 ohms is a much larger load than 100K ohms. Why? Because 10 ohms passes much more current, loading down the power supply.

Resistance drops when multiple resistors (POTs) are placed in parallel. As that resistance drops, the load increases. It's not necessarily a problem for you, but I wasn't sure what your POT values were...

Input Impedance is somewhat difficult to get a handle on.

A high input impedance is generally seen a good thing. High impedance devices require very little current to "do their thing." And very little current is consumed by them. When connected, it's almost like they aren't there. The input pins on the Arduino are on the order of megaohms, maybe 10s of megaohms (10,000,000 ohms).

The less current it takes to "run" a device, the less current needs to be available (and wasted) by whatever is supplying it. The POTs, for instance, can be high resistance value, and there will still be plenty of current for the ADC.

Contrast that with a very LOW input impedance device--like an 8 ohm speaker. It takes a lot of current to make that speaker move, and 8 ohms is a large load on the circuit. It certainly effects the rest of the circuit...

Output impedance is related, but in some ways opposite (we won't go there now).

At this point, I'd rip out every POT but one, and individually test each input pin...

Well, after I changed the names of all them from the names of the pins on the Arduino, it started working. I was working on another i'ble when I came upon this little problem.

Thank you very much for taking your time to explain all this to me!

Sure! Glad you got it sorted...

Your wiring looks good except for one problem - your leds are shorts to ground! Add a current limiting resistor to prevent letting the smoke out of your arduino pins! 1k is a really safe no-calculate value but you can calculate exactly what is needed to make them glow. Does your current setup work? Yes, for now - but your duino and or the leds will wear out VERY fast.

Seriously, you saw that???

Yeah, I know, I'm just too lazy to go upstairs and get a resistor :D
I was very surprised that they were still working!
Thanks to gmoon for telling me that I can't name them names of inputs, it works fine. So yes, this setup works! Thank you very much as well for helping me out!

yeah; I hope this behaviour isn't because of internal AtMega smokey smokey.

Better yet, operate on the regulated 5v after the onboard regulator of the Arduino so the max voltage IS the chip supply voltage, with each wiper going to its own analogue input.

Lastly, double check the code - see if the variables could be talking to each other...
something like

variable0 = analogRead(A0);
variable1 = analogRead(A1);
variable2 = analogRead(A2);
variable3 = analogRead(A3);
Serial.Println(variable0); //etc

Ok, so this is what my code looks like

int A1 = analogRead(11);
int pot1 = A1 * (10.0 / 1023.0);

Look good?

I'm not sure you should be declaring A1 every time.

int A1 = 0; //declare variable
int pot1 = 0;

then in loop
//pin: the number of the analog input pin to read from (0 to 5 on most //boards, 0 to 7 on the Mini and Nano, 0 to 15 on the Mega)
//are you using a mega? 11 isn't analog input on regular duino. A //floating (disconnected) pin will give a random number based on a lot of things

//check your pin numbers!
A1 = analogRead(pinnumber);
pot1 = A1 * (10.0 / 1023.0);