Coding help Pros

How would I code a “if pressed” I want it so when I press L1, my intake spins forword. When release, it stops. How do I do that?

Also I wanna code a back clamp so when I press the button, the backclamp goes up, and when released, back clamp goes down.

Note: This is all explained in C++, but the general logic should be the same if working in C.

It sounds like for both the intake code, and the clamp code, you want a hold button.

First, looking at the PROS documentation is incredibly valuable for knowing what to type for what actions, or detecting certain things. You could find it by clicking here. Make sure you are checking the documentation for YOUR version of PROS (the most current are versions 3 and 4, each having their own documentation)

You would want to put the following code into the opcontrol function, which should be in the main.cpp file.

if ( master.get_digital(DIGITAL_L1) ) {
   intakeMotor.move(100);
} else {
   intakeMotor.move(0);
}

The naming schemes of your controller or the intake motor are likely different, so be sure to retrofit this code into yours correctly.

The same general logic applies for the pneumatics code, instead using:

// Using PROS 4
piston.extend();
piston.retract();

// Using PROS 3
piston.set_value(true); // true for retract, false for extend

Good luck!!

1 Like

Thanks so much! I was looking into the .hp and .hpp files and I couldn’t find anything. I forgot about that Pros had a website