First : your pot are not mounted onto the motor
you can see the expected behaviour in this video
http://www.youtube.com/watch?v=oFnLDR2xGggand please find the explanation of the code here :
The code is written to put the simulator on middle position at start :
/* init position value*/
int DataValueL=512; //middle position
- if your pot is fully turned to max, as Arduino "reads" potentiometer value as motor position, Arduino believes that motor is in max position.
- but the order is to be in middle position
- so the Arduino will ask the motor to go reverse in order to go to middle position
- your motor is turning
- but while your pot keeps still, the motor will turn non stop !
- when you manually turn the pot backward to min, Arduino reads that motor is in min position
- but the order is still middle position, so Arduino will tell the motor to go forward
- motor runs non stop until the pot is in middle position
In the code, you have a "tolerance" parameter : when the pot is around middle position (<middle+tolerance and >middle-tolerance), the motor stops.
You can broader Tolerance value to stop your motor more easily manually.