this sounds simple but am having a hard time coding it.
I want to use 2 pots to drive 2 motors. when the pots are centred (trying to allow a little room for error here) the motors don't budge, but as you move further from the centre the motor speeds up in the direction (forward-forward reverse-reverse)
I have seen a lot of tutorials so far but nothing that is exactly what I want and my coding is really bad. any help is greatly appreciated

p.s. am using 2 sliding pots, an ardumoto shield and 2 motors.

First, forget that there are two motors and two pots, and concentrate on getting your logic correct for just one pot and one motor.
One simple way is to simply subtract 512 from your analogRead value, and if the result is less than zero, set the motor reverse bit.
Then, take the absolute value of the offset analogRead value and divide by two to give you your analogWrite value.

This method doesn't give you any dead-band in the middle of the pot's travel, but that is some extra simple logic.

I understand the subtracting method but how do I make it read 512 is stop and 511 is slow reverse? and 0 is full reverse?

freerpg:
I understand the subtracting method but how do I make it read 512 is stop and 511 is slow reverse? and 0 is full reverse?

Something like this

``````int slider = analogRead(Pin);

if (slider >= 500 && slider <= 523){
// Stop code here
}
if (slider < 500){
// Reverse code here
}
if (slider > 523){
//Forward code here
}
``````