Help with coding please - Arduino+AdaMotorshield+joystick

Thanks for your quick reply. I'm sorry if i was not clear enough in my request
as i said i'm quite new to Arduino :confused:

When i try to verify the code in get this error:

"redefinition of 'int analog pin"

sketch_sep27a_Stepper_test_with_pot_v1_02:8: error: redefinition of 'int analogPin'
sketch_sep27a_Stepper_test_with_pot_v1_02:7: error: 'int analogPin' previously defined here

As i stated earlier i managed to make the code work with one stepper and a potmeter.
what i have been trying is to add an extra motor and an ekstra potmeter.

with this code:

#include <AFMotor.h>

AF_Stepper motor1(225, 1);
int analogPin = 0; // potentiometer wiper (middle terminal)
//connected to analog pin 3
// outside leads to ground and +5V
int val = 0; // variable to store the value read
int prepos = 0;
int pos = 0; //0 to 224 .

void setup()
{
motor1.setSpeed(60); // 30 rpm
}

void loop() {

prepos = pos;
val = analogRead(analogPin); // read the input pin

pos = map (val, 0, 1024, 0, 224);

if (pos != prepos){
int diststep = pos - prepos;
if (diststep < 0) {
motor1.step(-diststep, BACKWARD, INTERLEAVE);
}
if (diststep > 0) {
motor1.step(diststep, FORWARD, INTERLEAVE);
}

}

}

Thanks again :slight_smile: