Log in

View Full Version : Potentiometers in Java


PeteG
29-01-2011, 12:17
Our team is trying to find a way to measure the position of our arm using a potentiometer. We're using Java this year and we can't find any classes that are for potentiometers.

Does anyone know the best way that we could program a potentiometer in Java to give us its position?

mwtidd
29-01-2011, 13:04
Our team is trying to find a way to measure the position of our arm using a potentiometer. We're using Java this year and we can't find any classes that are for potentiometers.

Does anyone know the best way that we could program a potentiometer in Java to give us its position?

I think you can use analog channel

PeteG
29-01-2011, 17:57
I think you can use analog channel

Awesome, thanks, I assume you mean the AnalogChannel class (there are a few others like AnalogModule, AnalogTrigger, etc.).

Would we use getVoltage() or getValue()? It might be getVoltage() since (I think) potentiometers just limit the voltage when the knob is turned. I've never used potentiometers before, though.

sjspry
29-01-2011, 18:53
It shouldn't matter, you will just obtain different values. getValue will be something more akin to a "percent" (but in a range of integral values), while getVoltage will be un-scaled to be a voltage.

IIRC, getValue will give you more resolution, but overall it won't matter.

PeteG
29-01-2011, 21:06
OK, we'll just pick one and go with it in the code. Thanks for your help.