Stepper motor code doesn't compile


const int dirPin = 8;
const int stepPin = 9;
 
const int steps = 200;
int microPausa = 1000;

void setup() {
pinMode(dirPin, OUTPUT);
pinMode(stepPin, OUTPUT);
}


void loop() {
 digitalWrite(dirPin, HIGH);  // Establezco una dirección


 for (int i = 0; i < steps; steps ; i++) {
   digitalWrite(stepPin, HIGH);
   delayMicroseconds(microPausa);
   digitalWrite(stepPin, LOW);
   delayMicroseconds(microPausa);
 }
 delay(1000);
 
 digitalWrite(dirPin, LOW);  // Cambio la dirección

 for (int i = 0; i < steps; steps ; i++) {
   digitalWrite(stepPin, HIGH);
   delayMicroseconds(microPausa);
   digitalWrite(stepPin, LOW);
   delayMicroseconds(microPausa);
 }
 delay(1000);

}
Compilation error: expected ')' before ';' token

You need to review your for loop syntax.

Also please change the topic title; it is misleading.

Fix the various program errors, and perhaps the stepper will work!

Welcome to the forum

    for (int i = 0; i < steps; steps; i++)

Look carefully at the parameters in the for loop initialisation

Why is the second use of the steps variable there ?

Also, where is the } at the end of the loop() function ?

1 Like

Yes it was so I changed it.

Thanks

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