origin stepper motor

hai good day.

i have a conveyor system about 2 meter long. i have some problem to origin back conveyor to home position.

byte directionPinCon = 30;
byte stepPinCon = 34;
int numberOfStepsCon = 15;
//byte ledPin = 7;
int pulseWidthMicrosCon = 1;  // microseconds
int microbetweenStepsCon = 100; // milliseconds - or try 1000 for slower steps
int sensor = 2;
void setup() {
  // put your setup code here, to run once:
int sensorStatus = digitalRead(sensor);

void loop() {
  // put your main code here, to run repeatedly:
if ( sensorStatus == HIGH ) {
  digitalWrite(directionPinCon, HIGH); 
  digitalWrite(stepPinCon, HIGH);
   // delayMicroseconds(pulseWidthMicrosCon); // this line is probably unnecessary
   digitalWrite(stepPinCon, LOW);
 else {


i want to stop stepper motor if the proximity sensor detect the metal plate that i put on conveyor but the conveyor did't stop. can anybody give the solution to me. thanks

So what actually happens when you run the program?

I think you need a variable to record the state of the system - perhaps call it okToMove

When the sensor is triggered your program should set okToMove = false; and the part of your program that makes the motor move should only do so if (okToMove == true) {

You have not told us how you would tell the system it is appropriate to start moving again so I have not addressed that.

If you use the AutoFormat tool it will indent your code to make it much easier to read.