Go Down

Topic: Potentiometer Confusion (SOLVED) (Read 1 time) previous topic - next topic

Caliber Mengsk

May 20, 2011, 12:25 am Last Edit: May 20, 2011, 10:47 pm by Caliber Mengsk Reason: 1
So, this is my first time messing with a potentiometer on the arduino. I have a simple script that checks each of the analog channels for values above 512, and the first (a0) just relays the mapped value to an led on pin 13 (softpwm). The confusing part is, after the pot gets a quarter or so the way through spinning, the led is at max brightness, and if I spin it further, the rest of the analog pins act as if switches have been turned on.

I can understand the pot going to full in only a quarter turn. It's just the wrong resistance level (10k pot), but what I don't get is why the rest of the analog pins are acting as if the switches are turned on. The only thing I can think of is they have a noise variance because I didn't feel like hooking up any resistors, but they shouldn't they always act like they are on? (Also, what size pot do I need to make a full turn = max on an arduino. I'm still fairly new to electronics, but shouldn't I need a smaller resistance pot? Like a 5k?)

I know it should be simple, and it's probably something that's my fault, but Can someone help me out a little?


If you have the pot hooked up correctly (as a voltage divider), all pots will give you the full range (or almost), from <= 10 to >= 1000. 

It should be +5v -> outer pin, analog input 0 to center pin, and GND to the other outer pin. 

As for the rest, if you don't have anything attached to them, they're just floating - their readings will be random, and should be ignored.

Caliber Mengsk

What does it mean if I have the pot hooked up right and it's still only getting a quarter turn to be at max?


It means you don't have it hooked up right, or your code is wrong.  Please show a picture and also paste your code here.

Caliber Mengsk

May 20, 2011, 04:11 am Last Edit: May 20, 2011, 04:13 am by Caliber Mengsk Reason: 1
I forgot to mention I already used the map function to resize the input. (Why I didn't just divide by 4 instead of using the map function, I don't know though.)

As far as the code with respect to the quarter turn, I had this:
SoftPWMSet(13, floatMap(analogRead(0),0,1024,0,255));
//(Float map is the same as Map, but with floats instead. Better precision in many cases, IMO, especially when scaling up instead of down.)

and changing it to be the simpler math,
SoftPWMSet(13, analogRead(0)/4);

As for hooking it up, I have it like the "New" one in this image:

where pin three is going to A0, and +5v input is from the 5v rail of an Arduino Duemilonove (spelling wrong I'm sure... O-o I always get it wrong XD).


Have you tried just printing out the output from the analogRead() method?  It would be helpful to know if the problem is in reading the analog pin or in converting it for softPWM.

Caliber Mengsk

I found out what my problem was. I was doing the 255 max value for softPWM, and it's percentage based, 100 max. That's why I was off. Seems to be working well now though.

Thanks for the help, It's much appreciated.

Go Up