Controlling a stepper motor with a RC transmitter

Hello, I'm new to Arduino and would appreciate some help on my project. I'm trying to control a stepper motor with a RC transmitter. I would like the stepper to continually turn clockwise when the signal from the RC receiver is less than 1200. I would like the stepper to continually turn counterclockwise when the signal is higher than 1700. I would like the stepper to stop when the signal is appox. 1500.

Equipment I'm using:
MicroStepper Driver ST M5045
Stepper Motor: 23HS30-2804S
ARDUINO UNO

PIN 2 = INPUT from RC Receiver
PIN 9 = DIR
PIN 10 = PUL

It works and turns the stepper the correct ways and stops. However, when just left to run in one direction it stops as the program loops. I would like non-stop turning until I put the switch back to the center (approx 1500).

#include <Stepper.h>
int ch2 = 0;

const int stepsPerRevolution = 200;

// initialize the stepper library:
Stepper myStepper(stepsPerRevolution, 9, 10);

void setup() {
pinMode(2, INPUT); //from RC reciever ch2 SC switch on Transmitter
myStepper.setSpeed(200);
digitalWrite(9, LOW);
digitalWrite(10, LOW);
Serial.begin(9600);
}

void loop() {
//get current values of RC receiver
ch2 = pulseIn(2, HIGH, 20000);

Serial.print("ch2 ");
Serial.println(ch2);
Serial.println("------------");
delay(500);

if (ch2 < 1200)
{
Serial.println("clockwise");
myStepper.step(1000);
}
else if (ch2 > 1700)
{
Serial.println("counterclockwise");
myStepper.step(-1000);
}
}

Rail_Remote_Sensing_Robot.ino (696 Bytes)