How to record steps a stepper motor takes and how to rotate it backward and forward with analog input?
I analyzed your code written in the comment and assuming that it works I prepared a modification that should prevent the motor from moving when the sensor is pressed the same way all the time. The noise values you have to adjust yourself. Make it as low as you can.

I cannot test this code, because I don't have your hardware. Treat it as pseudo code.

#include &lt;Stepper.h&gt;
// change this to the number of steps on your motor 
#define STEPS 200
#define NOISE 0.1

Stepper stepper(STEPS, 8, 9);
int previous = 0;
void setup() {
  // set the speed of the motor to 30 RPMs 
  stepper.setSpeed(100);
}

void loop() {
  // get the sensor value 
  float val = analogRead(A0);

  float difference = previous - val; 

  if(difference &lt; -NOISE || difference &gt; NOISE)
  {
    stepper.step(val - previous);
    previous = val;
  }
}