Help needed i can not seem to find the error with thi code

#include <AccelStepper.h>
// defines pins numbers
const int stepPin = 3;
const int dirPin = 2;
const int enPin = A5;
const int limitPin = A1;
const int stepPin1 = 8;
const int dirPin1 = 7;
const int enPin1 = A4;
const int limitPin1 = 6;
void setup() {

pinMode(limitPin, INPUT);
// Sets the two pins as Outputs
pinMode(stepPin, OUTPUT);
pinMode(dirPin, OUTPUT);

pinMode(enPin, OUTPUT);
pinMode(limitPin1, INPUT);
// Sets the two pins as Outputs
pinMode(stepPin1, OUTPUT);
pinMode(dirPin1, OUTPUT);

pinMode(enPin1, OUTPUT);
digitalWrite(enPin, LOW);
digitalWrite(enPin1, LOW);

}
void loop() {

if ( digitalRead(limitPin) == LOW) {
digitalWrite(stepPin, HIGH);
delayMicroseconds(500);
digitalWrite(stepPin, LOW);
delayMicroseconds(500);

}
}
else {

if ( digitalRead(limitPin1) == LOW) {
digitalWrite(stepPin1, HIGH);
delayMicroseconds(500);
digitalWrite(stepPin1, LOW);
delayMicroseconds(500);
}

Please, what error?

Does it compile? No, share the error.

Otherwise describe what it does that it shouldn't or doesn't do what it should.

We not mind readers. :expressionless:

a7

sorry it will mot compile gives this error expected unqualified-id before 'else'

Hmmm, try copying the entire error so we not crawling through your code looking for what has been pointed out to you more precisely.

a7

And maybe read the pinned post and learn how to properly show us your code - looks like a missing brace, but who can know if you just dump your code into the post?

There's a pinned thread at the top,of this forum category outlining how to get the best help here. Read it, need it.

a7

#include <AccelStepper.h>
// defines pins numbers
const int stepPin = 3;
const int dirPin = 2;
const int enPin = A5;
const int limitPin = A1;
const int stepPin1 = 8;
const int dirPin1 = 7;
const int enPin1 = A4;
const int limitPin1 = 6;
void setup() {

  pinMode(limitPin, INPUT);
  // Sets the two pins as Outputs
  pinMode(stepPin, OUTPUT);
  pinMode(dirPin, OUTPUT);

  pinMode(enPin, OUTPUT);
  pinMode(limitPin1, INPUT);
  // Sets the two pins as Outputs
  pinMode(stepPin1, OUTPUT);
  pinMode(dirPin1, OUTPUT);

  pinMode(enPin1, OUTPUT);
  digitalWrite(enPin, LOW);
  digitalWrite(enPin1, LOW);

}
void loop() {

  if ( digitalRead(limitPin) == LOW) {
    digitalWrite(stepPin, HIGH);
    delayMicroseconds(500);
    digitalWrite(stepPin, LOW);
    delayMicroseconds(500);



  }
}
else {
 
  if ( digitalRead(limitPin1) == LOW) {
    digitalWrite(stepPin1, HIGH);
    delayMicroseconds(500);
    digitalWrite(stepPin1, LOW);
    delayMicroseconds(500);
  }
}
}

The complete } else { ... }clause is behind loops closing }.

Use the autoformat in the IDE and find this! Check loop closely!

const int enPin = A5;
const int limitPin = A1;
const int stepPin1 = 8;
const int dirPin1 = 7;
const int enPin1 = A4;
const int limitPin1 = 6;
void setup() {

  pinMode(limitPin, INPUT);
  // Sets the two pins as Outputs
  pinMode(stepPin, OUTPUT);
  pinMode(dirPin, OUTPUT);

  pinMode(enPin, OUTPUT);
  pinMode(limitPin1, INPUT);
  // Sets the two pins as Outputs
  pinMode(stepPin1, OUTPUT);
  pinMode(dirPin1, OUTPUT);

  pinMode(enPin1, OUTPUT);
  digitalWrite(enPin, LOW);
  digitalWrite(enPin1, LOW);

}
void loop() {

  if ( digitalRead(limitPin) == LOW) {
    digitalWrite(stepPin, HIGH);
    delayMicroseconds(500);
    digitalWrite(stepPin, LOW);
    delayMicroseconds(500);

  }
}
else {

  if ( digitalRead(limitPin1) == LOW) {
    digitalWrite(stepPin1, HIGH);
    delayMicroseconds(500);
    digitalWrite(stepPin1, LOW);
    delayMicroseconds(500);
  }





code will now compile but second stepper will not move

Please post the code of "now"..... and please autoformat the code in the IDE and use code tags, the </> symbol.

#include <AccelStepper.h>
#include <Servo.h>
// defines pins numbers
const int stepPin = 3;
const int dirPin = 2;
const int enPin = A5;
const int limitPin = A1;
const int stepPin1 = 8;
const int dirPin1 = 7;
const int enPin1 = A4;
const int limitPin1 = 6;

Servo myservo;
Servo myservo1;

#define servoPin 5
#define servoPin1 4
void setup() {
  myservo.attach(servoPin);
  myservo1.attach(servoPin1);
  pinMode(limitPin, INPUT);
  pinMode(limitPin1, INPUT);
  pinMode(stepPin, OUTPUT);
  pinMode(dirPin, OUTPUT);
  pinMode(enPin, OUTPUT);
  pinMode(stepPin1, OUTPUT);
  pinMode(dirPin1, OUTPUT);
  pinMode(enPin1, OUTPUT);
  digitalWrite(enPin, LOW);
  digitalWrite(enPin1, LOW);

}
void loop() {

  if ( digitalRead(limitPin) == LOW) {
    digitalWrite(stepPin, HIGH);
    delayMicroseconds(500);
    digitalWrite(stepPin, LOW);
    delayMicroseconds(500);

  }

  else {

    if ( digitalRead(limitPin) == LOW) {
      digitalWrite(stepPin1, HIGH);
      delayMicroseconds(500);
      digitalWrite(stepPin1, LOW);
      delayMicroseconds(500);
    }
  }
}

Always show us a good schematic of your proposed circuit.
Show us a good image of your ‘actual’ wiring.
Give links to components.

Look at the "if" code block and the "else" code block. They are the same. Useless but the stepper ought to turn.

Step up and post schematics.

It's okey but why an analog pin and not a digital pin?

Why not "INPUT_PULLUP"? Do You have any external pull up/down resistor?

Schematics please!

thank you that helped a lot