Catapult w/ Limit Switch


I am currently using C++ for Robot Mesh on the V5 system and was wondering. What is the best way to program a limit switch for a catapult auto reload in driver control? I want to program it to stay down while the limit switch is pressed, then allow to shoot when a button on the controller is pressed. Then when the limit switch isn’t pressed, then the catapult returns to the pressed position.



I use for my catapult a Potenciometer. So when it goes to a degree it will stop and it works very well. I was thinking on doing the limit switch or bumper switch but it would not work because the catapult will recharge and the limit switch or bumper switch could end up breaking.


I use a potentiometer as well. also @Manuel , why do you have vex IQ parts on your bot?t


Vex U can use Vex IQ parts. We didnt have the angel bars to do the design we had so we used the welcome kit lego toys and use them.


huh didn’t know that cool


I was using a potentiometer on my Catapult, but recently switched from a regular axle to a high strength axle. Unfortunately, the high strength axle isn’t compatible with the potentiometer, so I have to resort to a limit switch. Thanks for the suggestion though! Could any of you guys help me program a limit switch though?


I need help with the statements for True or False in the driver control. I have it set up to run with a button in the correct direction, but I need to program the limit switch to stop the motors when pressed.


If I understand you correctly, you should be able to do that within an if statement. Just check if the limit switch is pressed, and if true stop the motor.

vex::motor catapult_motor(PORT, blah, blah);
vex::digital_in limitSwitch(PORT); //limit switches are digital inputs
 if(controller.get_digital(BUTTON)){catapult_motor.move_velocity = 50;}//do whatever makes your robot shoot here
 else if(!limitswitch.get_value()){catapult_motor.move_velocity = -50;}//pull back the catapult as long as the limitswitch is not pressed
 else{catapult_motor.move_velocity = 0;}//if the limit switch is pressed, stop moving the catapult


Thats soo cool i like that idea


What is this C++ for Robot Mesh or VCS?


Here’s what I have so far:

 if (Controller1.ButtonL2.pressing())
            Catapult.spin(vex::directionType::fwd, 100,vex::velocityUnits::pct);
            Catapult2.spin(vex::directionType::rev, 100,vex::velocityUnits::pct);
        else if (LimitSwitch.pressing())
            Catapult.spin(vex::directionType::fwd, 0,vex::velocityUnits::pct);
            Catapult2.spin(vex::directionType::rev, 0,vex::velocityUnits::pct);
            Catapult.spin(vex::directionType::fwd, 0,vex::velocityUnits::pct);
            Catapult2.spin(vex::directionType::rev, 0,vex::velocityUnits::pct);

What am I forgetting or doing wrong?


on the

            Catapult.spin(vex::directionType::fwd, 0,vex::velocityUnits::pct);
            Catapult2.spin(vex::directionType::rev, 0,vex::velocityUnits::pct);

I think you’d want to replace the 0 with -100, because when nothing is being pressed you want the catapult to go to the pressed position. Right?

If you want your catapult to stay down when the limit switch is pressed, you might want to set it to brake or hold till the button is pressed rather than just not move at all. I’ve never built a catapult though so probably wrong.


I shouldn’t need it to hold because I have a ratchet on the catapult, but thanks for the help. I’ll see if that works.


Didn’t know of the ratchet, it shouldn’t be necessary then.


It worked, thanks for the help!


No problem, happy to help. It’s nice to know I can actually help at programming.