Skip to main content
deleted 62 characters in body
Source Link
Michel Keijzers
  • 13k
  • 7
  • 43
  • 59

Although the motor (global) variables are defined in a header files, they are included in both cpp files, thus defined twice.

Make them extern, and than define them in the motor.cpp file.

(I haven't tried in the compiler, but try something like):

In motor.h, change

Servo motor1, motor2, motor3, motor4;
Servo motorArray[4] = {motor1, motor2, motor3, motor4};

to

extern Servo motor1, motor2, motor3, motor4;
extern Servo motorArray[4];

In motor.cpp, add:

Servo motor1, motor2, motor3, motor4;
Servo motorArray[4] = {motor1, motor2, motor3, motor4};

As a side note, use consts for values 4 and 2000.

Although the motor (global) variables are defined in a header files, they are included in both cpp files, thus defined twice.

Make them extern, and than define them in the motor.cpp file.

(I haven't tried in the compiler, but try something like):

In motor.h, change

Servo motor1, motor2, motor3, motor4;
Servo motorArray[4] = {motor1, motor2, motor3, motor4};

to

extern Servo motor1, motor2, motor3, motor4;
extern Servo motorArray[4];

In motor.cpp, add:

Servo motor1, motor2, motor3, motor4;
Servo motorArray[4] = {motor1, motor2, motor3, motor4};

Although the motor (global) variables are defined in a header files, they are included in both cpp files, thus defined twice.

Make them extern, and than define them in the motor.cpp file.

In motor.h, change

Servo motor1, motor2, motor3, motor4;
Servo motorArray[4] = {motor1, motor2, motor3, motor4};

to

extern Servo motor1, motor2, motor3, motor4;
extern Servo motorArray[4];

In motor.cpp, add:

Servo motor1, motor2, motor3, motor4;
Servo motorArray[4] = {motor1, motor2, motor3, motor4};

As a side note, use consts for values 4 and 2000.

Source Link
Michel Keijzers
  • 13k
  • 7
  • 43
  • 59

Although the motor (global) variables are defined in a header files, they are included in both cpp files, thus defined twice.

Make them extern, and than define them in the motor.cpp file.

(I haven't tried in the compiler, but try something like):

In motor.h, change

Servo motor1, motor2, motor3, motor4;
Servo motorArray[4] = {motor1, motor2, motor3, motor4};

to

extern Servo motor1, motor2, motor3, motor4;
extern Servo motorArray[4];

In motor.cpp, add:

Servo motor1, motor2, motor3, motor4;
Servo motorArray[4] = {motor1, motor2, motor3, motor4};