Skip to content

Instantly share code, notes, and snippets.

@leoforney
Created August 24, 2015 21:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save leoforney/4fe2352e901fe3ae6948 to your computer and use it in GitHub Desktop.
Save leoforney/4fe2352e901fe3ae6948 to your computer and use it in GitHub Desktop.
// This is the power that only has a max of 75%...
int multPower = 0.75;
// your loop statement here...
public void loop() {
// Get numeric value from gamepad1 on the left trigger, can be changeable...
float leftTriggerPressed = gamepad1.left_trigger;
if (leftTriggerPressed != 0) {
// If the left trigger is slightly to all the way pressed, set the power to a max of 45%
multPower = 0.45;
} else {
// If the left trigger is released set power back to 75%
multPower = 0.75;
}
// after some lines of code
motorRight.setPower(right * multPower);
motorLeft.setPower(left * multPower);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment