Robot Arm Help

Our team would like our arm to be able to hold in place at a certain position during the driver-control period. Think of it this way: When you hold a certain button to make the arm go up/down, after releasing hold the button, the arm would stay in that position. Any ideas how to do this? I am personally against this decision, but my teammates really want this feature, so yeah. Thanks for listening to my TED talk.

I’m not a great programmer but I can generally explain what to do (I think).
Set a “zero” position for your arm, usually this is at the very bottom, always start your drives from this zero position, it makes sure the robot knows where the arm is.
Now with simple if-then statements, all you have to write is “If button L1 is pressed, move to position x”, that x position is based off the zero you set.
If your zero is at the bottom of your robot, and position x is 90° rotated from that, it will rotate 90° and probably be in a good scoring position. But if you set your zero in that 90° position, it will continue to rotate another 90° which is probably not good.

Forgive me, I didn’t explain this very well, and if a real programmer would like to make corrections feel free, but that is my normie way of explaining it.


This can be achieved by setting the stopping of the motors to hold so they will hold at that position. This is how it’s done:


As long as you put these lines of code before the arm code, you’re good. Here is an example of how this can be done with a function that sets the stoppings of all your arm motors to hold:

void setArmHold() {

To call the function, simply put this in the code in the usercontrol while loop (presumably before the arm code):


Hope that helps, and good luck with your programming! :grin:


Also worth noting that the motors should not be the primary thing holding your arm up against gravity - most of that work should be done by rubber bands. If you rely on just motor braking to hold an arm up your motors will soon overheat.


Hi, our team had to do the exact thing, and you don’t really have to create a whole new callback for holding the arm in place. It’s always best to keep your code clean.

void armUp(){
while (Controller1.ButtonR1.pressing() == true) {
if (Controller1.ButtonR1.pressing() == false){

This worked for me. So when I’m pressing the R1 button, the arm goes up and stays there when I release it. Anothor solution is telling your arms to move up to a certain degree when you press a button. In that case, it would be something like

void liftUp(int v){
LeftArm.setVelocity(v, percent);
RightArm.setVelocity(v, percent);
LeftArm.spinToPosition(400,degrees, false);

However, although this depends on your driver’s taste and skills, I don’t recommend using the second example because then since the angles are slightly different every time, sometimes it tries to lift up too much and sometimes too little. This problem can still be solved if you use a lot of absolute value equations but tbh that’s just a headache. I hope this helps.