#include const int stepsPerRevolution = 200; // change this to fit the number of steps per revolution // for your motor int sensorPin = A0; int sensorValue = 0; // initialize the stepper library on pins 8 through 11: Stepper myStepper(stepsPerRevolution, 8, 9, 10, 11); void setup() { pinMode(A0, INPUT); myStepper.setSpeed(60); // set the speed at 60 rpm: } void loop() { sensorValue = analogRead(sensorPin); if (sensorValue >= 150) { // step one revolution in one direction: Serial.println("clockwise"); myStepper.step(stepsPerRevolution); delay(2000); // step one revolution in the other direction: Serial.println("counterclockwise"); myStepper.step(-stepsPerRevolution); delay(2000); } }