Q: Controlling the stepper motor speed with potentiometer I'm trying to build a small rotating table with variable speed with EasyDriver, NEMA17 stepper motor, potentiometer, and arduino. I am having some trouble with the code. Basically, the motor rotates the same speed no mather of the potentiometer position. Also the motor starts to rotate when I put my potentiometer near the end position. And rotates constantly only in that position.
I have checked all the hardware components and they are working fine. I guess the problem is in the code. Putting an LED diode on the step pin I see that arduino is working fine, but stepper motor does not move accordingly. 
void setup() {
  // put your setup code here, to run once:

  //STEP PIN
  pinMode (13, OUTPUT);

  //POTPIN
  pinMode (A5, INPUT);

  //DIRPIN
  pinMode (12, OUTPUT);

  digitalWrite (12, LOW); 
}

void loop() {
  // put your main code here, to run repeatedly:

  int potValue =  analogRead (A5) / 8;

  digitalWrite (13, HIGH);

  delay (potValue);

  digitalWrite (13, LOW);

  delay (potValue);
}


A: I believe that your problem is using the delay() function with wrong range of values for this type of motor driver. 
Your delay represents the time to make a step, and your rotor speed depends on how many steps has your motor. I recommend playing with delays between 10 and 2000 microsseconds to begin with. Your current delay function is being set between 0 and 128 milliseconds, which is a lot slower than your motor's requirements. 
To solve this problem, try using the map() to correctly set up the delay for your motor. I also recommend, instead of delay(), use delayMicroseconds() function.
Basicaly, you can transform your potentiometer values to a correct delay value using:
int delayValue= map(potValue, 0, 1023, 10, 2000);

Your code will be something like the code below:
void setup() {
  pinMode (13, OUTPUT); //STEP PIN
  pinMode (A5, INPUT); //POTPIN
  pinMode (12, OUTPUT); //DIRPIN
  digitalWrite (12, LOW); 
}

void loop() {
  int potValue =  analogRead (A5); // Read from potentiometer
  int delayValue= map(potValue, 0, 1023, 10,2000); // Map potentiometer value to a value from 300 to 4000

  digitalWrite (13, HIGH);
  delayMicroseconds(delayValue);
  digitalWrite (13, LOW);
  delayMicroseconds(delayValue);
}

