I have a linear actuator with a potentiometer within it to give feedback to the position of where the actuator is. the range is from 0-10K ohm (fully extended). There are three wires red white and black. I assume the white is the wire that goes into the analog input and red and black are +5 and gnd accordingly. I tried just reading the analog value and printing it to the serial screen, but it showed up as 0 even when the actuator is moved.
Can anyone help me get the potentiometer values to work?
Thanks in advance.
There are three wires red white and black. I assume the white is the wire that goes into the analog input and red and black are +5 and gnd accordingly.
That's a good assumption but not necessarily true. Is this a powered device or just a passive pot? If the latter then it's really a question of what the center "wiper" terminal is. Do you have a part number or datasheet we can reference?
Seeing your sketch would be helpful too.
The Aussie Shield: breakout all 28 pins to quick-connect terminals
Can you disconnect it and measure the pot directly?
the actuators are Thomson Electrak 1SP. The potentiometer is separate from the power source to the actuators.
Pot = analogRead(0);
And I have been able to read the potentiometer value directly using a multimeter so I know for a fact it works properly.
Try setting it up like the Reference page example
Analog reads are only 10 bits, use int instead of float, value readings will be 0 to 1023 representing 0 to 5V.
Also: It takes about 100 microseconds (0.0001 s) to read an analog input, so the maximum reading rate is about 10,000 times a second.
So your loop is likely going way too fast.
int analogPin = 3; // potentiometer wiper (middle terminal) connected to analog pin 3
// outside leads to ground and +5V
int val = 0; // variable to store the value read
Serial.begin(9600); // setup serial
val = analogRead(analogPin); // read the input pin
Serial.println(val); // debug value
Thanks for the help, I got it to work! I am getting values 1023 when fully retracted and 400 when fully extended.