Hi all!
Working on my first arduino project and running into some problems. Basically I am reading the position of a potentiometer as a steering wheel and adjusting the speed on one of two motors to turn. I have included my code (please excuse its condition. its not complete and still has commented out Serial.print's from debugging) I am having two issues. The first is the readings from the POT. Since I am reading it from the A1 pin its value should be between 0 and 1023, which it is. What confuses me is that 513 is not at the centre of the knobs travel. Should it be?

Second, with the 'if' statement before the function call I don't understand why the function is being call continuously. I'm sure I should include more info, but its getting late and Im not sure what. Any help is GREATLY appreciated!!!
int oldValue = 0;
void setup() {}
void loop()
{
int potValue = analogRead(A1); //Read value from POT
if ( potValue != oldValue ) { //If POT value has changed
dualMotorSteering ( potValue ); //adjust motor speeds to control direction
oldValue = potValue ;
}
}
void dualMotorSteering (int sensorValue) {
Serial.begin(9600); // open serial communication (for dubugging)
int switchVal = 0;
int speedA = 256;
int speedB = 256;
//Serial.println ("in");
if (sensorValue < 512) { // Determine if the potentiometer is in a Center, LOC or ROC position
switchVal = 1;
}
else {
switchVal = 2;
}
switch(switchVal) {
case 1: // POT is LOC
speedB=(sensorValue /4); // Convert POT val to Speed val
if (speedB <= 4) { // If speed is below min, set to min
speedB = 1; }
if (speedB >= 256) { // If speed is above max, set to max
speedB = 256; }
// Serial.println ("c1");
break;
case 2: // POT is ROC
speedA=(sensorValue /4); // Convert POT val to Speed val
if (speedA <= 4) { // If speed is below min, set to min
speedA = 1; }
if (speedA >= 256) { // If speed is above max, set to max
speedA = 256; }
// Serial.println ("c2");
break;
analogWrite(speedBpin, speedB);
}
Serial.print (sensorValue, DEC);
Serial.print (" : ");
Serial.print (speedB, DEC);
Serial.print (" : ");
Serial.println (speedA, DEC);
//Serial.println ("out");
return;
}