Coding 1 motor on 2 buttons in pros ez template

I’m using the ez template in pros and I want to make one motor run on 2 different button. The reason for this is because one button runs the bottom stage and hood at the same time while another button runs just the bottom stage.

This runs both while below it runs only the bottom stage and PTO.

What I have for button L1 runs both at full speed and works but button Y it doe not run at full speed when it’s at 127.
If anyone knows how to get the bottom stage to run and full speed let me know. Any help is appreciated.

This is why we want to see all the code. I’ll guess that the 2 fragments you posted are in a loop. The first block sets the bottom to zero when it does not see the buttons pressed. A few lines later it gets set to 127. Then loop back, set to 0. Few lines set to 127. Lather, rinse, repeat.

Fix is to do all the buttons in the same set of code. Or write an explicit check for the buttons not being pressed to set the motor to zero.

3 Likes

You are telling the bottom intake to move at 0 speed and at 127 speed at the same time. In your else statement, replace bottom_intake.move(0); with

if (!master.get_digital(pros::E_CONTROLLER_DIGITAL_Y)) {
  bottom_intake.move(0);
}

which avoids the conflict between the button presses.

1 Like