Hi @jemartel, I can certainly try to help :-). The following should run all six motors forward for 5 seconds, then soft brake for 1 second, then all six motors backward for 5 seconds, then soft brake for 1 second, then repeat forever. I don't have a setup to try it with, but I think it should work. At least it compiles. Please let me know if I pulled it off. I should note that the notion of "forward" and "backward" is entirely dependent on how the motors are wired for polarity.
#include <Wicked_DCMotor.h>
int num_motors = 6;
Wicked_DCMotor motor1(M1);
Wicked_DCMotor motor2(M2);
Wicked_DCMotor motor3(M3);
Wicked_DCMotor motor4(M4);
Wicked_DCMotor motor5(M5);
Wicked_DCMotor motor6(M6);
Wicked_DCMotor *m[] = {&motor1, &motor2, &motor3, &motor4, &motor5, &motor6};
void setup(void){
Serial.begin(115200);
Serial.println("Test Motors");
}
void loop(void){
// move all motors forward for 5 seconds
Serial.println("Moving Motors Forward");
allMotorsForward();
delay(5000);
Serial.println("Applying Soft Brake");
allMotorsSoftBrake();
delay(1000);
// move all motors backward for 5 seconds
Serial.println("Moving Motors Backward");
allMotorsBackward();
delay(5000);
Serial.println("Applying Soft Brake");
allMotorsSoftBrake();
delay(1000);
}
void allMotorsSoftBrake(void){
for(int ii = 0; ii < num_motors; ii++){
m[ii]->setBrake(BRAKE_SOFT); // soft brake applied
}
}
void allMotorsForward(void){
for(int ii = 0; ii < num_motors; ii++){
m[ii]->setDirection(DIR_CW); // clockwise
m[ii]->setBrake(BRAKE_OFF); // no brake applied
m[ii]->setSpeed(255); // full speed
}
}
void allMotorsBackward(void){
for(int ii = 0; ii < num_motors; ii++){
m[ii]->setDirection(DIR_CCW); // counter-clockwise
m[ii]->setBrake(BRAKE_OFF); // no brake applied
m[ii]->setSpeed(255); // full speed
}
}