// Shows how to run AccelStepper in the simplest,
// fixed speed mode with no accelerations
#include "AccelStepper.h"

AccelStepper stepper; // Defaults to AccelStepper::FULL4WIRE (4 pins) on 2, 3, 4, 5

unsigned int speed = 0;
unsigned int lastSpeed = 0;

void setup()
{
  stepper.setMaxSpeed(1000);
  stepper.setSpeed(0);
}

void loop()
{
  speed = map(analogRead(A0), 0, 1023, 0, 1000);

  if (lastSpeed != speed)
    stepper.setSpeed(speed);

  if (speed > 0)
    stepper.runSpeed();
}