http://en.wikipedia.org/wiki/Stepper_motor #include #define HALFSTEP 8 // To know about HalfStep Stepper Motor plzz check the above mentioned link // Motor pin definitions #define motorPin1 8 // IN1 on the ULN2003 driver 1 #define motorPin2 9 // IN2 on the ULN2003 driver 1 #define motorPin3 10 // IN3 on the ULN2003 driver 1 #define motorPin4 11 // IN4 on the ULN2003 driver 1 #define switchPin 7 // Input signal from the switch whether ON or OFF // Initialize construtor 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(1000); stepper1.setSpeed(1000); stepper1.moveTo(40960); // 4096*10 steps for 10 rotations in 28BYJ-48 – 5V Stepper Motor //I hope you all to adjut the direction again within 10 rotations.....if no plzz feel free to disconect and connect again the microcontroller }//--(end setup )--- void loop() { if(digitalRead(switchPin) == HIGH) //Quite simple as you can see stepper1.run(); }