So our team just got v5s this year, so I am new to programming. I’m trying to find out how to move 2 motors at the same time using a controller. I’ve found similar answers on here, but they are not what i’m looking for. I think what i’m supposed to use is a motor_group, but I can’t find out how to make the motors move when pressing a button.
Try something like this:
if(Controller1.ButtonA.pressing()){
motor1.spin(forward,50,pct);
motor2.spin(forward,50,pct);
}
Or for the joysticks:
motor1.spin(forward,Controller1.axis3.value,pct);
motor2.spin(forward,Controller1.axis2.value,pct);
For motor_group, you can replace motor1 and motor2 from the previous statements with just the name of the motor group after initializing it like so:
motor_group motorgroupname(motor1, motor2);
2 Likes
Also – all of that needs to be placed in a while loop for it to work.
while(1){
if(Controller1.ButtonA.pressing()){
motor1.spin(forward,50,pct);
motor2.spin(forward,50,pct);
}
//OR
motor1.spin(forward,Controller1.axis3.value,pct);
motor2.spin(forward,Controller1.axis2.value,pct);
task::sleep(20);
}
1 Like