Hi, everyone.
I only know how to use L1, L2, R1, R2 Button to control the motor. But how to program other buttons, such as X Y A B and ↑↓→←. More importantly, how to program two joysticks, so that they can control the Robot’s movement. Thank you for your help!
The following code is what I accomplished.
int main() {
while(true){
//Raise the Arm Motor if the R1 ButtonR1 is pressed
if(Controller1.ButtonL1.pressing()){
Motor1.spin(directionType::fwd, 50, velocityUnits::pct);
Motor2.spin(directionType::fwd, 50, velocityUnits::pct);
}
else if(Controller1.ButtonL2.pressing()){
Motor1.spin(directionType::rev, 50, velocityUnits::pct);
Motor2.spin(directionType::rev, 50, velocityUnits::pct);
}
else if(Controller1.ButtonR1.pressing()){
Motor3.spin(directionType::fwd, 50, velocityUnits::pct);
Motor4.spin(directionType::fwd, 50, velocityUnits::pct);
}
else if(Controller1.ButtonL2.pressing()){
Motor3.spin(directionType::rev, 50, velocityUnits::pct);
Motor4.spin(directionType::rev, 50, velocityUnits::pct);
}
//Else stop the arm and hold its current position
else{
Motor1.stop(brakeType::hold);
Motor2.stop(brakeType::hold);
Motor3.stop(brakeType::hold);
Motor4.stop(brakeType::hold);
}
}
}