Getting potentiometer feedback from Actuonix linear actuator

Hello,

This is my first post and i'm pretty much a beginner jumping into the deep end like i usually do and end up not having a scooby doo about what to do so please take it easy on me. I'm using the arduino UNO, arduino motor shield and i have the Actuonix PQ12-30-12-P actuator. All i'm trying to do is learn about the actuator and how it works and how i can get it to do whatever i'd like. my first aim was to get it to move in and out which i did but currently i'm trying to get values from the potentiometer inside it and understand what i'm reading. I'm pretty much failing at this i think and was hoping someone could point me in the right direction and tell me what i've messed up with in the code.

Many thanks

//Actuator A
const int enA = 12;
const int brkA = 9;
int PotA = A0;
int val = 0;


void setup() {
  // put your setup code here, to run once:

  pinMode(enA, OUTPUT); //initialise chan A
  pinMode(brkA, OUTPUT); //initalise brake a
  pinMode(PotA, INPUT); //initalise potentiometer
  Serial.begin(9600);

}

void loop() {
  // put your main code here, to run repeatedly:

  val = analogRead(PotA);


  //forward
  digitalWrite(enA, HIGH); //extend arm
  digitalWrite(brkA, LOW); //disable brake
  analogWrite(3, 255);     //PWM
  
  delay(5000);
  Serial.write("extended: ");
  Serial.println(val);
  Serial.println("\n");
  

  //backward
  digitalWrite(enA, LOW);  //retract arm
  digitalWrite(brkA, LOW); //disbale brake
  analogWrite(3, 255);
  
  delay(5000);
  Serial.write("retracted: ");
  Serial.println(val);
  Serial.println("\n");

  digitalWrite(brkA, HIGH); //enable brake

  delay(1000);
  

}
  pinMode(PotA, INPUT); //initalise potentiometer

You do not need to call pinMode() for analog pins. They are input-only. What you are doing here is diddling with the digital nature of the pin, which is irrelevant when using the pin as an analog pin.

You haven't said anything about how the potentiometer is connected to the Arduino, or what problems you are having.

What kind of readings do you get for "val"?

Long before you write any code, tell us the options you chose for the actuator. 6 volt or 12 volt? Did you get the "P" option with a pot or did you get the "S" option with the limit switches.

IF you got the "P" option, what is the measured value of the pot? They list 5k ohms, +_ 50%, so pretty hard to compute a voltage divider resistor.

What do you have to power the actuator and what do you have to power the ARduino?

Paul

Thank you for the replies!

The actuator is the 12V with the potentiometer.

I've connected the actuators potentiometer to the 5V and GND with the wiper going to A0.

The values i've been getting for 'val' have been 20 and 13. Sometimes 21 and 14. Not really sure what that actually means.

I'm powering the actuator through the arduino which is just connected up via usb. I didn't really want to go all in with anything else just incase i really messed it all up. I'm showing how much i don't have a clue here i think.

Thank you all again for trying to help

After a slight switch in the wiring (got something backwards). The Values i'm getting are 51 for both

How many different values do you expect given that you only read the potentiometer ONCE at the top of loop() and then move the actuator twice?

Thanks for pointing that out. I've gone through a few tweaks and i've missed that. I'm an idiot. 51 and 25 are my values.