I have written a simple code to read the position of a linear actuator. When I run it, i am only getting values between 13 and 33.Should I not receive a reading of 0 and 1023 at the extreme positions? What is wrong?
For reference, i am using a heavy duty linear actuator with a 6" stroke and a built in potentiometer.
I am using an arduino uno and a MegaMoto Plus.
Currently I have the potentiometer wired as:
- White: GND
- Yellow: 5V
- Red:A5, analog in
int EnablePin1 = 13;
int PWMPinA1 = 11;
int PWMPinB1 = 3;
const int PotPin = A5; //Sets the input pin [1] for the potentiometer, Analog pin
int startvar = 0; // variable to be assigned to start program via serial monitor
char rx_byte = 0;
int currentposition=0;
unsigned long StartTime = millis();
void setup() {
Serial.begin(9600);
pinMode(EnablePin1, OUTPUT);//Enable the board
pinMode(PWMPinA1, OUTPUT);
pinMode(PWMPinB1, OUTPUT);//Set motor outputs
}//end setup
void loop() {
if ( Serial.available () > 0) { //See if input avalible
rx_byte = Serial.read(); // retrieves input character provided by user
if ((rx_byte > '0') && (rx_byte < '2')) { //Checks if input recieved to start. 1 is required entry
Serial.println ("Input Recieved, Starting"); // singals program is starting, commence loop
currentposition = analogRead(PotPin);
Serial.print("Position Readout (0-1023): ");
Serial.println(analogRead(PotPin));
}//end if
}//end main loop
}