[PROS] Using a potentiometer for setting catapult states

  1. last week

    OscarMNOVA12

    Jan 7 Event Partner, V5 Beta Tester Northern VA and Pittsburgh MASON, 12, 22172

    So I'm trying to use a potentiometer to hold the catapult in a loading state and then use a button to fire. I always want the catapult to be in a loading state unless I hit the button to fire.

    Here's the current code I have, with the potentiometer not included.

    void opcontrol() {
    	Controller master (E_CONTROLLER_MASTER);
    
    
    	lift.set_brake_mode(E_MOTOR_BRAKE_HOLD);
    	flipper.set_brake_mode(E_MOTOR_BRAKE_HOLD);
    
    	int straight;
    	int turn;
    
    	while (true) {
    		straight = master.get_analog(E_CONTROLLER_ANALOG_LEFT_Y);
    		turn = master.get_analog(E_CONTROLLER_ANALOG_RIGHT_X);
    
    		frontLeft = straight + turn;
    		frontRight = straight - turn;
    		backLeft = straight + turn;
    		backRight = straight - turn;
    
    		if(master.get_digital(E_CONTROLLER_DIGITAL_L1)) {
    			lift = 80;
    		}
    		else if(master.get_digital(E_CONTROLLER_DIGITAL_L2)) {
    			lift = -80;
    		}
    		else {
    			lift = 10;
    		}
    
    		if(master.get_digital(E_CONTROLLER_DIGITAL_DOWN)) {
    			catapult = 127;
    		}
    		else {
    			catapult = 0;
    		}
    
    		if(master.get_digital(E_CONTROLLER_DIGITAL_X)) {
    			intake = 105;
    		}
    
    		else if(master.get_digital(E_CONTROLLER_DIGITAL_B)) {
    			intake = -105;
    		}
    
    		else {
    			intake = 0;
    		}
    
    		if(master.get_digital(E_CONTROLLER_DIGITAL_R1)) {
    			flipper = 80;
    
    		}
    		else if(master.get_digital(E_CONTROLLER_DIGITAL_R2)) {
    			flipper = -90;
    		}
    		else {
    			flipper = 10;
    		}
    	}
    }

    The idea I have circulating for the potentiometer loading is in pseudcode:

     if (launch button pressed) { 
        if (potentiometer in loaded state) 
            launch
        else if(potentiometer in released state) 
           move to loaded state
     } else 
          move/maintain loaded state

    This is my quick thought on how to do it in PROS. Is there something I'm missing?

      if(master.get_digital(E_CONTROLLER_DIGITAL_DOWN)) {
    			if(loadingPot.get_value() > LOADING_STATE_MIN && loadingPot.get_value() < LOADING_STATE_MAX) {
    				catapult = 127;
    			} else if(loadingPot.get_value() < LOADING_STATE_MIN ) {
    				catapult = 70; // Move slowly to loading state for now
    			}
    		}
    		else {
    			catapult = 0;
    		}
 

or Sign Up to reply!