CONTROLLING STEPPER BY POTENSIOMETER

stepper potensio

#include <AccelStepper.h>
const int analogPin = A0;
#define HALFSTEP 8
// Motor pin definitions
#define motorPin1 12 // IN1 on the ULN2003 driver 1
#define motorPin2 11 // IN2 on the ULN2003 driver 1
#define motorPin3 10 // IN3 on the ULN2003 driver 1
#define motorPin4 9 // IN4 on the ULN2003 driver 1

// Initialize with pin sequence IN1-IN3-IN2-IN4 for using the AccelStepper with 28BYJ-48
AccelStepper stepper1(HALFSTEP, motorPin1, motorPin3, motorPin2, motorPin4);
void setup() {
stepper1.setMaxSpeed(1000);
stepper1.setAcceleration(10000);
stepper1.runToNewPosition(4096);//move 360 deg
delay(5000);

}//–(end setup )—

void loop() {
int analogValue = analogRead(analogPin);
stepper1.runToNewPosition(analogValue*4.17);

}