Programming Help for newbie

I thought I posted this earlier, but can’t find it.

I have always used If Else statements for programming buttons. However, this year, I’m trying to have certain motors on different programs, so I want to try Pressed Release. Below is the code and error. Any help is useful. I’ve truncated some code to make it more readable.

void AllIn(int SpeedPCT){
Intake.spin(directionType::fwd, SpeedPCT, velocityUnits::pct);
Toproll.spin(directionType::fwd, SpeedPCT, velocityUnits::pct);
Outtake.spin(directionType::fwd, SpeedPCT, velocityUnits::pct);
Uproll.spin(directionType::fwd, SpeedPCT, velocityUnits::pct);
void AllStop()

later in a while statement…


I am getting error code “cannot initialize a parameter of type ‘void (*()’ with an rvalue of type 'void”

Any help is appreciated.

You can’t use the pressed or released commands in a while statement.

The reason is because they set a callback. You define it once, and then every time the action is completed (in this case, button R1 gets pressed), it completes the function passed as a parameter.

If you put the code in a while loop, it will get constantly changed, and cause problems.

This may not be your only problem, but it probably is a problem.


After searching, I created a seperate Void Statement
Void AllInButton(){
Intake.spin(directionType::fwd,100, velocityUnits::pct);
Toproll.spin(directionType::fwd, 100, velocityUnits::pct);
Outtake.spin(directionType::fwd, 100, velocityUnits::pct);
Uproll.spin(directionType::fwd, 100, velocityUnits::pct);
It looks like having an variable after the AllIn caused the issue. Thanks

1 Like