4 Potentiometers with Arduino?

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?

19 answers
sort by: active | newest | oldest
Mar 12, 2013. 9:57 AMfrollard says:
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;
Mar 12, 2013. 10:07 AMgmoon says:
Yep, if he's using pin name constants as variable, that's a problem. I'm surprised the compiler allows it...
Mar 12, 2013. 6:07 AMgmoon says:
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...
Mar 12, 2013. 6:33 AMgmoon says:
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.
Mar 12, 2013. 8:34 AMfrollard says:
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
loop...

variable0 = analogRead(A0);
variable1 = analogRead(A1);
variable2 = analogRead(A2);
variable3 = analogRead(A3);
Serial.Println(variable0); //etc
delay(1000);
Mar 12, 2013. 9:51 AMfrollard says:
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);
Mar 12, 2013. 6:46 AMsteveastrouk says:
Asking ? I'd guarantee it ;-) WELL above pin Vmax (6 I think)
Mar 12, 2013. 8:35 AMfrollard says:
yeah; I hope this behaviour isn't because of internal AtMega smokey smokey.
Mar 12, 2013. 7:03 AMgmoon says:
Oops.

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.)
Mar 12, 2013. 8:59 AMgmoon says:
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).
Mar 12, 2013. 10:03 AMfrollard says:
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.
Mar 12, 2013. 9:54 AMgmoon says:
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...
Mar 12, 2013. 6:31 PMgmoon says:
Sure! Glad you got it sorted...

Pro

Get More Out of Instructables

Already have an Account?

close

PDF Downloads
As a Pro member, you will gain access to download any Instructable in the PDF format. You also have the ability to customize your PDF download.

Upgrade to Pro today!