Arduino Motor Shield Stepper Motor control with Joystick

Hi Ash

I amended the code accordingly but still no luck. Giving me one-liner codes won't really help me since I don't know arduino coding or any other type of programming to a huge extend.

Here is the code the last time with the changes...

#include <Stepper.h>

const int spr = 200; // motor steps per revolution
const int pwm_cha = 3;
const int pwm_chb = 11;
const int dir_cha = 12;
const int dir_chb = 13;
const int brake_cha = 9;
const int brake_chb = 8;

int Pot1 = A0;

Stepper stepper(spr, dir_cha, dir_chb);

void setup()
{
pinMode(Pot1, INPUT);
pinMode(pwm_cha, OUTPUT);
pinMode(pwm_chb, OUTPUT);
pinMode(brake_cha, OUTPUT);
pinMode(brake_chb, OUTPUT);
digitalWrite(pwm_cha, HIGH);
digitalWrite(pwm_chb, HIGH);
digitalWrite(brake_cha, LOW);
digitalWrite(brake_chb, LOW);
}

void loop()
{
int PVal=analogRead(Pot1);
if (PVal >= 507 || PVal <= 517)
{

}
if (PVal > 517 )
{
int K= map (PVal, 518,1023,0,75); // max is the value that you get from your experiment with the max speed of the stepper before stalling
stepper.setSpeed(K); //this set the speed of the stepper motor
stepper.step(spr); //this set the direction and the number of step it would take
}
if (PVal < 507 )
{
int K= map (PVal, 0,506,0,75); // max is the value that you get from your experiment with the max speed of the stepper before stalling
stepper.setSpeed(K); //this set the speed of the stepper motor
stepper.step(-spr); //this set the direction and the number of step it would take
}
}

For some reason nothing is happening.

But thanks anyway for your help. I'm sure I'll manage somehow somewhere eventually while searching the net. I need a solution quite urgent and can't struggle like this for too long.

Regards