problem with variable

I want to make a robot, drived with 2 stepper 28BIY-48 motors and ULN2003 drivers. I copied a code from internet and change it so it can control 2 motors, but it gives an error about that the var "motorPin1" not is defined, but in a line some lines above it is definend. What am i doing wrong?

#include <AccelStepper.h>
#define HALFSTEP 10

// Motor pin definitions
//==motorRight==\\
#define motorPin1  10    // IN1 on the ULN2003 driver 1
#define motorPin2  11    // IN2 on the ULN2003 driver 1
#define motorPin3  12    // IN3 on the ULN2003 driver 1
#define motorPin4  13    // IN4 on the ULN2003 driver 1
 
//==motorLeft==\\
#define motorPin5  6     // IN1 on the ULN2003 driver 2
#define motorPin6  7     // IN2 on the ULN2003 driver 2
#define motorPin7  8     // IN3 on the ULN2003 driver 2
#define motorPin8  9     // IN4 on the ULN2003 driver 2

// Initialize with pin sequence IN1-IN3-IN2-IN4 for using the AccelStepper with 28BYJ-48
AccelStepper stepper1(HALFSTEP, motorPin1, motorPin3, motorPin2, motorPin4);
AccelStepper stepper2(HALFSTEP, motorPin5, motorPin7, motorPin6, motorPin8);

void setup() 
{
  stepper1.setMaxSpeed(1000.0);
  stepper1.setAcceleration(100.0);
  stepper1.setSpeed(200);
  stepper1.moveTo(20000);

  stepper2.setMaxSpeed(1000.0);
  stepper2.setAcceleration(100.0);
  stepper2.setSpeed(200);
  stepper2.moveTo(20000);
}

void loop() 
{
  stepper1.run();
  stepper2.run();
}

When you decided to pretty up your comment:

//==motorRight==\\

you also created a bug. The \ character at the end of the line escapes the newline, which turns the following line into a comment. The same problem occurs in the next comment.

If you had turned compiler warnings on (File > Preferences > Compiler warnings > All) and taken note of the output in the black console window at the bottom of the Arduino IDE window, you would have gotten a helpful warning:

C:\Users\per\AppData\Local\Temp\arduino_modified_sketch_745202\sketch_sep21b.ino:5:1: warning: multi-line comment [-Wcomment]

 //==motorRight==\\

 ^

C:\Users\per\AppData\Local\Temp\arduino_modified_sketch_745202\sketch_sep21b.ino:11:1: warning: multi-line comment [-Wcomment]

 //==motorLeft==\\

 ^

This is why you should always have warnings set to the highest level and always pay attention to these very helpful warnings.

ah, thanks for the help. I never know that :slight_smile:

Pixelz_Studios:
ah, thanks for the help. I never know that :slight_smile:

You may not have known (knew) that, but you should now.