PROS Help

  1. 6 months ago

    Juster

    7 Dec 2017 Edmonton Alberta

    So started learning PROS today wondering how to write a if statement and else. So if you press a button motors turns on and if not pressed motors set to 0. Any help would be appreciated!

    Thanks Juster

  2. sazrocks

    7 Dec 2017 Arizona 2114V
    Edited 6 months ago by sazrocks

    This code would make the motor in port 1 move at 127 power when button 8D is pressed on the main joystick:

    while(true){  //infinite loop
      if(joystickGetDigital(1, 8, JOY_DOWN)){ //if button 8D is pressed
        motorSet(1, 127); //set the motor to 127
      }
      else{ //else (if button 8D is not pressed)
        motorSet(1, 0); //set the motor to 0
      }
      delay(20);  //Always have a delay in infinite loops
    }

    If you need basic programming help, there are plenty of C programming tutorials on the web and https://pros.cs.purdue.edu/api/ is very helpful for PROS-specific things.

  3. Juster

    7 Dec 2017 Edmonton Alberta

    Well thanks wondering why does it say "JOY_DOWN" does this mean where the button is. For example, if you want Button 8U you would replace it to "JOY_UP"
    That's one question, second one is if I want this for a lift you would place this in "lift.c" or somewhere else. Thanks again

  4. sazrocks

    7 Dec 2017 Arizona 2114V

    @Juster ; Well thanks wondering why does it say "JOY_DOWN" does this mean where the button is. For example, if you want Button 8U you would replace it to "JOY_UP"

    That is correct.

    @Juster ; That's one question, second one is if I want this for a lift you would place this in "lift.c" or somewhere else. Thanks again

    It depends on the structure of your program. For me this code could go in several different places, and I would just choose the place that is the cleanest and most organized.

 

or Sign Up to reply!