if your motor controller is the same as a L298 Motor controller ic that have 3 pin to control the motor speed and direction i would like to point out some important info
this is the data sheet for L298 http://www.st.com/internet/com/TECHNICAL_RESOURCES/TECHNICAL_LITERATURE/DATASHEET/CD00000240.pdf
if you go to page 6/13 and go to Figure 6 : Bidirectional DC Motor Control. there is a Table on how to give signal to the motor controller and what actually it does
ok in the table there are Ven which mean Enable, C and D which is PinA1 and PinA2 respectively.
Base on the Table
Enable = HIGH,C=HIGH,D=LOW then Motor will run in full speed at one direction
Enable=HIGH,C=LOW,D+HIGH then the motor will run at full speed on the other direction
Enable=HIGH,C=D, motor will hard stop. Mean that you have a hard time turning the motor
Enable=LOW,C&D Dont care(dont mean a thing if left high or low) Motor Flywheel, Essentially the motor is disconnected from the circuit. you can easily turn the motor shaft.
ok lets say driving the motor is the same as driving a car. If we were to pulse only the enable pin, and C and D would be at different state,its an equal to push fully the gas pedal, then release, do this a couple dozen of time and you essentially controlling the speed of the motor,
let say that your pulsing the C or D instead of Enable, its like your both your feet is at the brake and the pedal, first your push the gas to the max, then you push the brake to the max. yes you are controlling the motor but, you are wasting allot of energy in that kind of setup.
in your code
int Speed=map (pos,posRead, target,255,0);
analogWrite (PinA1, 30);
analogWrite (PinA2, 180);
what does this means.Your actually pulsing all the enable,PinA1 and PinA2. yes the motor will rotate, but there will be time that all the pin would be high and making the motor want to stop. there will also be time that the Enable is low, which make the motor Free wheeling . and there will be time that the motor will rotate to a certain direction. but all and all, i hope you would consider my explanation so you could make the motor run at its optimum speed.