|
Re: Programming Joystick Buttons to toggle a motor on and off
This is how my team did it.
// this is all in our autonomous loop....
bool buttonUp = leftStick->GetRawButton(1);
bool buttonDown = leftStick->GetRawButton(2);
bool buttonStop= leftStick->GetRawButton(3);
float elevatorSpeed; // this is the speed of our elevator
if (buttonUP){
elevatorSpeed(1.0);
}
else if (buttonDown){
elevatorSpeed(-1.0);
}
else if (buttonStop){
elevatorSpeed(0.0);
}
ElevatorMotor1->Set(elevatorSpeed); // elevator motors one and two are
ElevatorMotor2->Set(-elevatorSpeed);// on both sides of our elevator
|