Go Down

Topic: Motor Array (Read 1 time) previous topic - next topic



I have a relatively simple question about initializing a motor array. What I would like to do is set up an array with my 4 motors, but I get an error "cannot convert 'AF_DCMotor' to 'int' in initialization" Could this have to do with my initialization of the individual motors?

Code: [Select]

#include <AFMotor.h>

AF_DCMotor motor1(1);
AF_DCMotor motor2(2);
AF_DCMotor motor3(3);
AF_DCMotor motor4(4);

int allMotors[4] = {motor1, motor2, motor3, motor4};



The type of array that things are stored in needs to match the type of things being stored in the array. If you want to store ints in the array, the array type should be int. If you want to store AF_DCMotor objects in an array, the array type should be AF_DCMotor.


Thank you SO much. Works perfectly.

Go Up