#include <Stepper.h>
#define echoPin 2
#define trigPin 3

const int stepsPerRevolution = 200;
Stepper s(stepsPerRevolution, 8, 9, 10, 11);
long duration;
int distance;

void setup() {
  pinMode(trigPin, OUTPUT);
  pinMode(echoPin, INPUT);
  s.setSpeed(60);
}

void loop() {
  digitalWrite(trigPin, LOW);
  delayMicroseconds(2);
  digitalWrite(trigPin, HIGH);
  delayMicroseconds(10);
  duration = pulseIn(echoPin, HIGH);
  distance = duration * 0.034 / 2;
  if (distance > 10)
  {
    s.step(stepsPerRevolution);
  }
}