Two stepper motors with 2limit switch to control dependently

hey, guys am new to the forum and am having some issues. the code is working fine no code error but I want to add delay b/n the motors when one of the limit switches is pressed and wait for the delay and start the motor when I am trying to do this the motor step per revolution is decreased and how can I fix this issues thanks.
// Declare Stepper Motor used pins
#define dirPin1 12
#define stepPin1 13
#define stepPin2 11
#define dirPin2 10
const int limit1 = 23;// limit switch of cover open clik
const int limit2 = 24;// limit switch of cover close click

void setup() {
// Set up stepper motor
pinMode(stepPin1, OUTPUT);
pinMode(dirPin1, OUTPUT);

//Set up 2 limit switch
pinMode(limit1 , INPUT);
pinMode(limit2 , INPUT);

}
void loop()
{

if(digitalRead(limit1) == LOW)
{
digitalWrite(dirPin1,HIGH);
digitalWrite(stepPin1,HIGH);
delayMicroseconds(1000);
digitalWrite(stepPin1,LOW);
}
else{
digitalRead (limit1 == HIGH);
digitalWrite(stepPin1,LOW);
}

if(digitalRead(limit1) == HIGH)
{
if(digitalRead(limit2) == LOW)
{

digitalWrite(dirPin2, LOW);
digitalWrite(stepPin2 , HIGH);
delayMicroseconds(1000);
digitalWrite(stepPin2 , LOW);

}
}
else{
digitalRead(limit1==LOW);
digitalRead(limit2==HIGH);
digitalWrite(stepPin2,LOW);
}
}

Hi @davetesfaye

welcome to the arduino-forum.

Your description is too short and too unclear to be able to help.
I will not speculate about multiple options what your wanted functionality is.

For receivng good and effective help you should follow the advice that is given here

best regards Stefan

???

Also please edit and make real sentences. It might help someone decode what you mean.

What was your intent with the following lines of code:

    digitalRead(limit1 == LOW);
    digitalRead(limit2 == HIGH);

How are your limit switches wired?

Now, we know that is based on the physical configuration of the motor armature and is physically impossible. Since you do not count the steps in your program, how did you conclude the motor is loosing steps?

Seems contradictory.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.