Help with digital out information

Hi there,

Sorry if I’m getting annoying, so we’re trying to figure out a way to use 2 buttons to turn on and off our pneumatics, is there a way to make it so one button keeps the valve open while the other button releases the air?

Also, trying to figure out a good function to use in auto so we can hold the goal during an auto run, I found this in the API

void vex::digital_out::set ( bool value )

would I just use that to create a function for it? Like:

void clampH(int value){
void vex::digital_out::set ( bool value );

}

I absolutely hate regular C++ API/doxygen with a passion. Super confusing and hard to find useful information. I feel ya. Heres a helpful link that answers your question:

Note: “piston” is the name of the piston that you gave it in the motor and sensors setup.

2 Likes

two buttons control pneumatics.

digital_out pneumatic = digital_out(10);
if (Controller1.ButtonX.pressing()) {
      pneumatic.set(true);
    } else if (Controller1.ButtonY.pressing()) {
      pneumatic.set(false);
    } 
  }

You can change ButtonY and ButtonX to the buttons of your choice.
Replace pneumatic to the name you give to pneumatic and the port.

4 Likes

Thank you guys, any chance you might know how to make this into a function for auto? I haven’t looked through the whole other posts that were mentioned, just thought I’d ask.

Thanks.

You can make a toggle function like this

void toggleClamp(){
  clamp.set(!clamp.value());
}

Or you can just set the value manually

clamp.set(value);
1 Like