would this work for pneumatics?
If that is in the driver control while (1) than that should work, I don’t see anything wrong with that
Oh I forgot the while loop thx
if i change it to
if (Controller1.ButtonX.pressing()){
Back.set(true);
}
else if (Controller1.ButtonX.pressing()){
Back.set(false);
}
would this work?
Are you trying to make a toggle (if you press X once, the pneumatics open, and if you press it again, then they close, and it continues to go through that cycle)?
If so, what I would do is create a global boolean variable, like this:
bool backStatus = false;
(To make it global, just place it outside of your function)
Then, in your driver control:
if (Controller1.ButtonX.pressing()) {
backStatus = !backStatus;
Back.set(backStatus);
}
That should work to create a toggle for your pneumatics.
Be careful with this, you need a way to keep it from repeating, I do it like this
if (Controller1.ButtonX.pressing()) {
if (no_repeat==1){
backStatus = !backStatus;
Back.set(backStatus);
no_repeat = 0;}
}else{
no_repeat=1;}
should define no repeat as a bool?
Very true. Alternatively, you could put the code in a .pressed() callback. Either way, it should work.
Yeah, define it as another global boolean variable.
like
if (controller1.ButtonX.pressed()){
}
?
No, a pressed callback would be:
Controller1.ButtonX.pressed(backToggle);
(Keep in mind, no if statement)
Then define a function named backToggle (before your user-control function) that does whatever you need it to do.
void backToggle(){
backStatus = !backStatus;
Back.set(backStatus);
}
would this be how i define a function? cuz it gives me error
Should be. What is your error?
oh i just put it in front of the void usercontrol
another question
if (Controller1.ButtonL1.pressing()){
arm.spin(vex::directionType::fwd, 100, vex::velocityUnits::pct);
}
else if(Controller1.ButtonL2.pressing()){
arm.spin(vex::directionType::fwd, 100, vex::velocityUnits::pct);
}
else{
arm.stop(vex::brakeType::hold);
}
even with the button my arm doesn’t move
Can we see more of the code? I can’t tell with just this snippet.
Pneumatic toggle, was covered earlier in another thread:
I moved that part in front of ring controls and it worked
Change it to:
if(Controller1.ButtonL1.pressing())
{
arm.spin(fwd);
}
else if(Controller1.ButtonL2.pressing())
{
arm.spin(reverse);
}
else arm.stop(vex::brakeType::hold);
How would you do this in Pros